I have converted a VB6 program to VB.Net. The program runs and seems to operate about 80% ok. I am having difficulties understanding how some of the for references work.
In VB6 I have code like
frmComms.MSComm1.PortOpen = True
' if port already used by other app then warn user and go back to initial screen
If (Err.Number = PORT_ALREADY_USED) And (GlManualCom = MANUAL) Then
frmDetection.Hide
MsgBox rs.LoadResString(ErrMesxxx), vbCritical + vbOKOnly, rs.LoadResString(ErrMesxyz)
Call frmSelection.RefreshSettings
Unload Me
frmSelection.Show
Exit Sub
ElseIf Err.Number = INVALID_PORT_NUMBER Then ' Invalid port number
frmDetection.Hide
MsgBox rs.LoadResString(ErrMes19Sub), vbExclamation + vbOKOnly, rs.LoadResString(ErrMes19Title)
Call frmSelection.RefreshSettings
Unload Me
frmSelection.Show
Exit Sub
ElseIf Err.Number = DEVICE_NOT_OPEN Then ' This device is not open
frmDetection.Hide
MsgBox rs.LoadResString(ErrMeszzz) , vbCritical
Call frmSelection.RefreshSettings
Unload Me
frmSelection.Show
Exit Sub
End If
These frmSelection references refer to the actual object in VB6, but in Vb.Net do they refer to the object or to some static reference. In other places in the code, it will set a public variable in the VB6 form as "frmSelection.CancelFlag = True", but trying to trace the code, I can not determine that this 'frmSelection.CancelFlag' is actually affecting my code. I get the feeling that I should be using an object reference to the 'frmSelection'. Like 'objSelection = new frmSelection', then I can set the variable using the object; objSelection.CancelFlag = True.
I used a program to convert the VB6 code to VB.Net, so maybe it is ok to refer to these items 'statically'. By 'static' I mean it in the C++ sense; that you can refer to variables of a class without ever creating the class.
In VB6, I was under the impression that the first reference to a form would create and load the form, maybe that was not true. But in VB.Net if I place a break point in the form Load event, it will not stop there even though there are many places in the code that are continuously using functions of the form.
I have tried to convert some of the frmXYZ references to objXYZ to see if that changes the outcome, but that did not appear to. I created a completely global variable instead of using the public variable in the form and that did work.