PDA

Click to See Complete Forum and Search --> : String Declare Error


buddu
Sep 20th, 2002, 03:54 AM
I have Simple Problem with Declaring Variables. This is my Program.

<%@ Page Language="VB" %>
<script runat="server">
Dim stm as String
stm="prasad"

</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>

I got the Following Error

Compiler Error Message: BC30188: Declaration expected.
Source Error:
Line 2: <script runat="server">
Line 3: Dim stm as String
Line 4: stm="prasad"

MarkusJ_NZ
Sep 20th, 2002, 04:10 AM
Have you tried placing the code in a routine?

Private Sub setString()

Dim stm as String
stm="prasad"

End sub

buddu
Sep 20th, 2002, 04:19 AM
It is working fine. But
why should Declare the Variable inside the Sub procedure?

any reason..? here the in between of <Server> </server> is Code block only so why not we assign the value over there.?

Wins
Sep 20th, 2002, 04:20 AM
Hi Buddu,

Its simple. Just try to place your code, i mean variable assignment should be inside subroutine.You can't assign a variable outside subroutine.

Cander
Sep 20th, 2002, 08:23 AM
Dim stm as String
stm="prasad"

wont work outside a procedure.

Dim stm as String = "prasad"

will work