|
-
Oct 1st, 2001, 10:02 AM
#1
Thread Starter
New Member
Need basic help on looping...
Forgive me but I am an old mainframe programmer that uses VB occasionally. Writing a gui for my package and can't figure out something. VB is event driven which is kinda weird to me. I can handle most things but I have a main routine that, if my link configuration has not been setup it shows another form to get the parms, then, when I get back I get the scoop from the registry. There is no getting back though (as I am sure you know). I need to get back to where I was in the routine I was in originally. I have a loop in the main process that looks like this (the timer was put in there to avoid a hard loop but, of course, it does nothing either):
Public Sub HostConnect()
Dim gotit As Integer
Timer2.Interval = 10000 'wait about 15 seconds
'gotta get our connection parameters, if not there then fetch them
gotit = 0
While gotit = 0
HostName = GetSetting("DMcom", "Host", "name", "notfound")
HostIP = GetSetting("DMcom", "Host", "name", "notfound")
HostPort = GetSetting("DMcom", "Host", "name", "notfound")
If HostName = "notfound" Or HostIP = "notfound" Or HostPort = "notfound" Then
ConnectSettingsfrm.Show
If FormLostFocus = True Then
' if we lost focus, wait for a bit
Timer2.Enabled = True
End If
Else
gotit = 1
End If
Wend
' ok, got parms, now connect
End Sub
Sorry to be a bother but I've just got some sort of mental block going here...
-
Oct 1st, 2001, 10:07 AM
#2
PowerPoster
If i'm understanding you correct, then it should return to where it left off in the preceeding sub, like this example
VB Code:
Public Sub DoSomething()
Dim i As Long
For i = 0 To 100
Debug.Print i
Next i
End Sub
Private Sub Command1_Click()
MsgBox "About to start Sub..."
DoSomething
MsgBox "Finished with sub..."
End Sub
-
Oct 1st, 2001, 10:09 AM
#3
Retired VBF Adm1nistrator
How about this :
VB Code:
Public Sub HostConnect2()
Dim EverythingOk As Boolean
EverythingOk = True
EverythingOk = InStr((GetSetting("DMcom", "Host", "name", "notfound") & GetSetting("DMcom", "Host", "ip", "notfound") & GetSetting("DMcom", "Host", "port", "notfound")), "notfound") = 0
If EverythingOk Then
'connect to server
Else
'show screen to get settings from user.
'allow user to cancel connection from there, or try to connect again
'the connect option should then call this sub again
End If
End Sub
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|