VbScript

  • Thread starter Thread starter Ana Rita
  • Start date Start date
A

Ana Rita

Hello to all.

I'm trying to do call a vbscript sub in one page aspx.

My vbscript sub is in a file with the extension (vbs) and
it looks like this:

Sub Mens (strmens)

Msgbox strmens

End sub

In the aspx page I do this in page_load:

Button1.Attributes.Add("onclick", "vbscript:Mens'" &
Hello & "''")

When I click in Button1 it shows the message.

My problem begins when I call the function in the
Button1_Click (aspx)

I do something like this:
Dim Message as string
Message="Hello"
Dim str as new stringBuilder
str.Append("<script language='vbscript'>")
str.Append("Mens ' "& Message &" ' ")
str.Append("</script>")
RegisterStartupScript("FichaAptidao.aspx", str.ToString)

When I click in Button1 it gives me this error message:

"Microsoft VBScript runtime error: Wrong number of
arguments or invalid property assignment: Mens"

I can understand why it gives me this error.

Can anyone help me?

Thank you all.

Ana Rita
 
Ana Rita said:
Hello to all.

I'm trying to do call a vbscript sub in one page aspx.

My vbscript sub is in a file with the extension (vbs) and
it looks like this:

Sub Mens (strmens)

Msgbox strmens

End sub

In the aspx page I do this in page_load:

Button1.Attributes.Add("onclick", "vbscript:Mens'" &
Hello & "''")

When I click in Button1 it shows the message.

My problem begins when I call the function in the
Button1_Click (aspx)

I do something like this:
Dim Message as string
Message="Hello"
Dim str as new stringBuilder
str.Append("<script language='vbscript'>")
str.Append("Mens ' "& Message &" ' ")
str.Append("</script>")
RegisterStartupScript("FichaAptidao.aspx", str.ToString)

You are attempting to take the entire StringBuilder object and cast it as a
string, not the string IN the StringBuilder. Try this:

RegisterStartupScript("FichaAptidao.aspx", str.ReadToEnd)

Which extracts the string from the SB.

By the way, why in the world are you still using VBScript in .NET?
 
Back
Top