PDA

Click to See Complete Forum and Search --> : If statement won't work


Insane Killa
Jan 11th, 2000, 04:58 AM
Ok the I have a form which gets hidden and then another form loads and is supposed to determe what it does due to the values on the last form from a combo box plus an option box or what ever there called I'll give an example of the simple code I am trying to use:

If Form3.Combo1.Text = "Ashenforest" + Form3.Option1.value = True Then
Image1.Picture = LoadPicture("Ashen1.bmp")
Image1.Height = Screen.Height
Image1.Width = Screen.Width
End If

If Form3.Combo1.Text = "Ashenforest" + Form3.Option2.value = True Then
Image1.Picture = LoadPicture("Ashen1w.bmp")
Image1.Height = Screen.Height
Image1.Width = Screen.Width
End If

If Form3.Combo1.Text = "Ashenforest" + Form3.Option3.value = True Then
Image1.Picture = LoadPicture("Ashen1w.bmp")
Image1.Height = Screen.Height
Image1.Width = Screen.Width
End If

now it won't load the picture for some reason, I know it something to do with the option part because when I took out the option part on one of them it worked fine... but I need it to determine which option has been picked.... anyone know what my problem is???

thanx

MartinLiss
Jan 11th, 2000, 05:13 AM
Change your "+" sings to "&". VB thinks you are trying to add something. Also your code would be slightly faster if you did the following. That way VB won't have to go through 3 If statements even if the 1st one happens to be true.

Select Case True
Case Form3.Combo1.Text = "Ashenforest" & Form3.Option1.value = True
Image1.Picture = LoadPicture("Ashen1.bmp")
Image1.Height = Screen.Height
Image1.Width = Screen.Width
Case Form3.Combo1.Text = "Ashenforest" & Form3.Option2.value = True
Image1.Picture = LoadPicture("Ashen1w.bmp")
Image1.Height = Screen.Height
Image1.Width = Screen.Width


Case Form3.Combo1.Text = "Ashenforest" & Form3.Option3.value = True
Image1.Picture = LoadPicture("Ashen1w.bmp")
Image1.Height = Screen.Height
Image1.Width = Screen.Width
End Select



------------------
Marty

LG
Jan 11th, 2000, 05:20 AM
Hi, there. Actually you have to change + to And
If Form3.Combo1.Text = "Ashenforest" AND Form3.Option1.value = True Then ...

Larisa

MartinLiss
Jan 11th, 2000, 06:36 AM
LG is right! Boy am I embarrased :o

------------------
Marty

Tonio169
Jan 11th, 2000, 04:14 PM
Dim sBitmap as String

With Form3
If .Combo1.Text = "Ashenforest" Then

' Since only one option can be selected at a ' time it is safe to do this:

If .Option1 Then sBitmap = "Ashen1.bmp"
If .Option2 Then sBitmap = "Ashen1w.bmp"
If .Option3 Then sBitmap = "Ashen1w.bmp"
Image1.Picture = LoadPicture(sBitmap)
Image1.Height = Screen.Height
Image1.Width = Screen.Width

End If
End With