jodyglidden
asked on
Syntax error Declaration Expected
Anyone see why I'm getting the declaration expected error?
<%@ Page Language="VB" %>
<%@ import Namespace="Microsoft.Win32 " %>
<script runat="server">
dim Accountskey as RegistryKey
right here--> Accountskey = Registry.CurrentUser.OpenS ubKey("Sof tware", False)
for each strAccount in Accountskey.getvaluenames( )
strAccounts = strAccounts & strAccount
next
Label1.text = strAccounts
</script>
<html>
<head>
</head>
<body>
<form runat="server">
Done
<asp:TextBox id="TextBox1" runat="server"></asp:TextB ox>
<asp:Label id="Label1" runat="server">Label</asp: Label>
<!-- Insert content here -->
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ import Namespace="Microsoft.Win32
<script runat="server">
dim Accountskey as RegistryKey
right here--> Accountskey = Registry.CurrentUser.OpenS
for each strAccount in Accountskey.getvaluenames(
strAccounts = strAccounts & strAccount
next
Label1.text = strAccounts
</script>
<html>
<head>
</head>
<body>
<form runat="server">
Done
<asp:TextBox id="TextBox1" runat="server"></asp:TextB
<asp:Label id="Label1" runat="server">Label</asp:
<!-- Insert content here -->
</form>
</body>
</html>
I am not sure why u r getting the error over there, your error should be in the following for loop
for each strAccount in Accountskey.getvaluenames( )
strAccounts = strAccounts & strAccount
next
Label1.text = strAccounts
If you you have not declared neither strAccount or strAccounts
you did not seem to declare them as strings prior to using them. thats all the syntax errors i can see
for each strAccount in Accountskey.getvaluenames(
strAccounts = strAccounts & strAccount
next
Label1.text = strAccounts
If you you have not declared neither strAccount or strAccounts
you did not seem to declare them as strings prior to using them. thats all the syntax errors i can see
Hi jodyglidden,
ryerras is correct - the problem is with strAccount and strAccounts, not with the OpenSubKey method
Regards!
B..M
ryerras is correct - the problem is with strAccount and strAccounts, not with the OpenSubKey method
Regards!
B..M
ASKER
Even if I add the strAccount and strAccounts Dim statements I am still getting a Declaration error for the statement mentioned above.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, that worked. I just changed the sub name to Page_Load
Private Sub DoesKeyExist
Dim regVersion As Microsoft.Win32.RegistryKe
regVersion = _
Microsoft.Win32.Registry.C
If regVersion Is Nothing Then
regVersion = _
Microsoft.Win32.Registry.C
End If
End Sub
Also, here you are trying to acces the registry on the server. Does user has permission to access the registry? Here are some links that might be helpful:
http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT11.asp
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2874&lngWId=10
Best, Nauman.