Hey guys, I've been programming VBA for a while now, and I recently started developing straight VB appliactions for some peers. However, I must admit my VBA knowledge is much more extensive than my VB knowledge, and I've run into a few problems (common beginner problems, I'm sure). On any note, I have some code that I've attached below:
Now, in VBA I know I can have different routines, functions, and classes to call and utilize, but I don't know how to make it work for VB. I have created an executable from this code, but I think it just runs through the global variables and then stops. Is there a way to get the executable to start in a certain sub routine when it begins the run? Can I continue to use routines as I have in VBA? Any help is very much appreciated! Thanks!Code:Public gblUserID 'String
Public gblUserPass 'String
Public gblAttackType 'Integer
Public gblAttackWho 'Integer
Public Sub Main()
'The main area of the code, this is where you enter.
'Start by asking the user some questions - put some error checking here to make sure they enter valid options
On Error Resume Next
Call GetUserInputs
If (Err.Number <> 0) Then
MsgBox "Your enteries were invalid. Please re-run the program and try again."
Exit Sub
End If
On Error Goto 0
End Sub
Private Sub GetUserInputs()
'Create the opening pop-up box
Set startIE = CreateObject("InternetExplorer.Application")
'Set that start box defaults
startIE.Navigate "about:blank"
startIE.ToolBar = False
startIE.Resizable = False
startIE.StatusBar = False
startIE.Width = 340
startIE.Height = 340
'Set up the height and width
With startIE.Document.ParentWindow.Screen
startIE.Left = (.AvailWidth - startIE.Width) \ 2
startIE.Top = (.AvailHeight - startIE.Height) \ 2
End With
'Loop until ready
Do While startIE.Busy: Wscript.Sleep 100: Loop
'Create the inner HTML for the box
startIE.Document.Body.InnerHTML = "<DIV ALIGN=""left""><P>Mouse: 1 - Rat: 2 - Chicken: 3 - " _
& "Dog: 4 - Cat: 5 - Bear: 6 - Dragon: 7</P>" & vbCrLf _
& "<P>Monster Number: <INPUT TYPE=""text"" SIZE=""2"" ID=""monster""</P>" & vbCrLf _
& "<P>1 for Strength, 2 for Defense: <INPUT TYPE=""text"" SIZE=""2"" ID=""attacktype""</P>" & vbCrLf _
& "<P>Username: <INPUT TYPE=""text"" SIZE=""20"" ID=""username""</P>" & vbCrLf _
& "<P>Password: <INPUT TYPE=""password"" SIZE=""20"" ID=""password""></P>" & vbCrLf _
& "<P><INPUT TYPE=""hidden"" ID=""OK"" NAME=""OK"" VALUE=""0""><INPUT TYPE=""submit"" VALUE="" Submit "" " _
& "OnClick=""VBScript:OK.Value=1""></P></DIV>"
'Show the completed box
startIE.Visible = True
'Keep looping until "Submit" is selected
On Error Resume Next
Do Until (startIE.Document.All.OK.Value = 1 Or startIE.Visible = False): Script.Wait 300: Loop
On Error GoTo 0
'Grab all our values
gblAttackWho = CInt(startIE.Document.All.monster.Value)
gblAttackType = CInt(startIE.Document.All.attacktype.Value)
gblUserID = CStr(startIE.Document.All.username.Value)
gblUserPass = CStr(startIE.Document.All.password.Value)
'Get rid of the start box
startIE.Quit
Set startIE = Nothing
End Sub

