-
March 19th, 2003, 11:56 AM
#1
King of the Mermaids
VB Help
I have been teaching myself VB. I have an old version, version 3 and I am running win2000.
I an getting an error message on the following code.....
Sub cmdExit_Click ()
Dim Message As String
Dim DialogType As Integer
Dim Title As String
Dim Response As Integer
' The message of the dialog box.
Message = "Are you sure you want to quit?"
' The dialog box should have Yes and No buttons,
' and a question icon.
DialogType = vbYesNo + vbQuestion
' The title of the dialog box
Title = "The Message Program"
' Display the dialog box and get user's response.
Response = MsgBox(Message, DialogType, Title)
' Evaluate the user's response.
If Response = vbYes Then
End
End If
End Sub
The error message I get is:
Variable not defined! for vbYesNo. I tried to remove it but it went staight to vbquestion an errored there too.
Has these button constants changed? Is it a version conflicit? Does anyone know?
-
March 21st, 2003, 05:13 PM
#2
Registered User
And the envelope please....
Hello VB Explorer,
I have never used VB3, but I have used VB 1.0 for Dos and VB5 and 6. It looks to me like you need to do
lngDialog_Type = VBYesNO or VBExclamation
However I'm not sure if those two types can even be combined in VB.
I do however know that you can do:
Dim lngDialogType as Long
lngDialog_Type = vbYesNO or vbDefaultButton1
would make yes the default choice on a yes/no dialog.
Good Luck man. IF you can afford it I highly recommend buying VB6 pro or better still enterprise edition. The price should be fairly reasonable if that's too expensive get yourself a copy of VB5 ASAP. Keep in mind that VB3 is 16 bit and nobody will want to use your programs or be all that impressed by such an outdated skill. Nonetheles, it's astronomically better than nothing. Also if you want VB1 for dos it's available online and is abandonware by now. Go to www.FileSearching.com and search for VBDOSPRo.zip or VB1Dos.zip or something like that.
Happy Programming,
Christian Blackburn
-
March 21st, 2003, 05:16 PM
#3
Registered User
Getting Help with Coding
Also I recommend you make PlanetSourceCode.com your second home while trying to learn how to program in VB. There's also some good newsgroups out there:
fj.comp.lang.visualbasic
microsoft.public.vb.winapi
microsoft.public.vb.dos
microsoft.public.vb.general.discussion
Also you can fill out a free technical support request at Protonic.com.
-Christian
-
March 21st, 2003, 05:35 PM
#4
King of the Mermaids
I appreciate the reply!! I talked to a friend of mine that programs in VB and he basically said the same thing.
"Your trying to program VB 3.0 and a 200 world. Get Version 6!!!" So it looks like I may be upgrading to VB .Net ought to be the latest and greatest..
-
March 24th, 2003, 01:00 PM
#5
RESPONSE should be an integer. To find out what that integer will be in both senarios write this:
Response = MsgBox(Message, DialogType, Title)
msgbox response
After you run and select either yes or no, a value is created and will be displayed in a dialogue box.
To each his/her own.
-
March 25th, 2003, 04:28 PM
#6
Registered User
Hi Guys,
CGK is right that the response should be in the integer data type, but his naming conventions are a bit lacking. Most professional programmers use a 3-letter prefix prior to the variable name so in this case you would say:
Dim intResponse as Integer
intResponse=Msgbox("Do you like mangos?", vbYesNo, "Got Fruit?"
If intResponse = vbYes then
MsgBox "Good, diets centered around fruit result in optimal athletic performance, longevity, and overall sex apeal."
else
Msgbox "Bummer dude, you're destined to be lard *** for the rest of your days?"
end if
-
March 26th, 2003, 10:21 AM
#7
King of the Mermaids
I appreciate all the replies. I just got my greedy hands on VB.net. Very different but the code I entered about works like a champ. Thanks!!!
-
March 27th, 2003, 08:51 AM
#8
Registered User
Re: And the envelope please....
Originally posted by seier
Hello VB Explorer,
I have never used VB3, but I have used VB 1.0 for Dos and VB5 and 6. It looks to me like you need to do
lngDialog_Type = VBYesNO or VBExclamation
However I'm not sure if those two types can even be combined in VB.
I do however know that you can do:
Dim lngDialogType as Long
lngDialog_Type = vbYesNO or vbDefaultButton1
would make yes the default choice on a yes/no dialog.
Good Luck man. IF you can afford it I highly recommend buying VB6 pro or better still enterprise edition....
Yes, thet CAN be combined, at least in VB6. I agree with the upgrade ideea however...
Protected by Glock. Don't mess with me!
-
March 27th, 2003, 05:31 PM
#9
King of the Mermaids
Just an FYI, I got the code to work by adding the following code and replacing the appropriate Dialogbox button commands...
Const MB_OK = 0, MB_OKCANCEL = 1
Const MB_YESNOCANCEL = 3, MB_YESNO = 4
Const MB_ICONSTOP = 16, MB_ICONQUESTION = 32
Const MB_ICONEXCLAMATION = 48MB_ICONINFORMATION = 64
Const MB_DEFBUTTON2 = 0, IDYES = 6, IDNO = 7
-
March 27th, 2003, 06:07 PM
#10
Registered User
Hi Diver,
Based on what I could see the only thing wrong was:
DialogType = vbYesNo + vbQuestion
should have been vbYesNo or vbQuestion. However in your version of VB the values might not be built in so then yes creating constants like you did makes sense. Either way I'm glad you figured things out. The fact that vbYesNo and the like aren't built in is exactly why you should be using VB5 or better.
Adios Amigo,
Christian
-
April 1st, 2003, 12:56 AM
#11
Avatar Goes Here
DialogType = vbYesNo + vbQuestion
seems to me also that this is your problem. As its been quite a few months since ive used vb, i cant give you the correct syntax, I just know that what you have isnt right
:::Asus A8N-Sli Premium:::AMD 3500+ @ 2.4ghz:::2x80GB 8mb cache RAID0 Array:::GeForce 7800GTX OC:::2GB Corsair XMS Memory:::500 Watt Enermax Liberty PSU:::16x Lite-on DVDRW:::
Counter Strike Source Forum and Server @ http://www.nvpclan.com -=Ninjas Vs. Pirates=-
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
|
|
Bookmarks