Problem with declaration of a UDT

Marvin Adams

New member
Joined
May 12, 2008
Messages
1
Programming Experience
3-5
Hey everyone,

I'm currently rewriting an application from VB6 to VB.NET. I am facing a huge problem with the new Structure concept.

This is my code:

Public Class frmMain
Structure AppInfoStruct
Dim Mode As Integer
Dim Edition As Integer
End Structure

Dim AppInfo As New AppInfoStruct
AppInfo.Mode = 1
End Class

The problem: The IDE underlines the line "AppInfo.Mode = 1" and says: "Declaration expected". What am I doing wrong? I want to use AppInfo as a global variable.

Thanks for your help
Marvin
 
You can't set variables outside of a method, except when creating. If you want AppInfo.Mode to be 1, you will need to do this inside of the structures constructor.
 
Back
Top