Valhalla Legends Forums Archive | Visual Basic Programming | Stupid Problem

AuthorMessageTime
Forged
[code]
Private Sub mnuedit_Click()
intWhich = 1 'The Browser knows to open the edit menu after choosing a file
frmBrowse.Show

End Sub

Private Sub mnuload_Click()
intWhich = 0 'The Browser knows not to open the edit menu after choosing a file
frmBrowse.Show

End Sub
[/code]

[code]
Private Sub Command1_Click(Index As Integer)

Select Case Index

Case Is = 0
strProfile = File1.Path & "\" & File1.FileName

  If intWhich = 0 Then
    Unload Me
  ElseIf intWhich = 1 Then
    Call Load
    frmSetup.Show
    Unload Me
  Else
    MsgBox "?"
  End If

Case Is = 1
Unload Me

End Select

End Sub
[/code]

in my modDeclare Module.
[code]
'Random Variables
Dim intWhich As Integer
[/code]

For some reason no matter what I do I get the "?" message box, I originally though maybe you were unable to use nested case statements, but when I switched to an if statement I came up with the same error, so I changed my Which variable from an int to a string and it still does not work.  If someone could help me It would be much appreciated.
August 12, 2005, 2:37 AM
K
Um, are you declaring a variable in the global/form scope named "strWhich" ?
August 12, 2005, 2:42 AM
Quarantine
Additonally why are you storing numerical data as a string?
Just declare the global variable as an integer.
August 12, 2005, 2:46 AM
Forged
yes strWhich is declared globally, and it was initally declared as an int, but for some reason or another that did not work either so I changed it to a string to see if that would make it work.

#Edit
I have now replaced strWhich with intWhich and now intwhich is never given a value and simplly closes frmbrowse.
The code from the first post has been changed to match the current situation.
August 12, 2005, 2:48 AM
The-FooL
[quote author=Forged]
intwhich is never given a value and simplly closes frmbrowse.
[/quote]

Figure out why it's not being given a value.  Are your methods being called?
August 12, 2005, 4:18 PM
Forged
there is no reason for it to not to be given a value, I even added intwhich = 4 in frmBrowse on form_load
still acts like the value is 0
August 12, 2005, 4:24 PM
Quarantine
add Option Explicit at the top of the code and make sure your variable is global.
August 12, 2005, 5:03 PM
Forged
works fine after adding Option Explicit, thank you sir.
August 12, 2005, 5:21 PM
Quarantine
No problem
August 12, 2005, 6:10 PM

Search