VB Help
Results 1 to 11 of 11

Thread: VB Help

  1. #1
    King of the Mermaids Diver01's Avatar
    Join Date
    Mar 2000
    Location
    Minnisoooda (cold wasteland)
    Posts
    1,443

    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?
    W

  2. #2
    Registered User seier's Avatar
    Join Date
    Sep 2002
    Location
    Sacramento, CA
    Posts
    92

    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
    Thanks,
    Christian Blackburn
    www.RawSeattle.org

  3. #3
    Registered User seier's Avatar
    Join Date
    Sep 2002
    Location
    Sacramento, CA
    Posts
    92

    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
    Thanks,
    Christian Blackburn
    www.RawSeattle.org

  4. #4
    King of the Mermaids Diver01's Avatar
    Join Date
    Mar 2000
    Location
    Minnisoooda (cold wasteland)
    Posts
    1,443
    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..
    W

  5. #5
    Registered User
    Join Date
    Aug 2000
    Location
    Middle of nowhere
    Posts
    473
    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.

  6. #6
    Registered User seier's Avatar
    Join Date
    Sep 2002
    Location
    Sacramento, CA
    Posts
    92
    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
    Thanks,
    Christian Blackburn
    www.RawSeattle.org

  7. #7
    King of the Mermaids Diver01's Avatar
    Join Date
    Mar 2000
    Location
    Minnisoooda (cold wasteland)
    Posts
    1,443
    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!!!
    W

  8. #8
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,494

    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!

  9. #9
    King of the Mermaids Diver01's Avatar
    Join Date
    Mar 2000
    Location
    Minnisoooda (cold wasteland)
    Posts
    1,443
    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
    W

  10. #10
    Registered User seier's Avatar
    Join Date
    Sep 2002
    Location
    Sacramento, CA
    Posts
    92
    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
    Thanks,
    Christian Blackburn
    www.RawSeattle.org

  11. #11
    Avatar Goes Here Radical Dreamer's Avatar
    Join Date
    Jan 2001
    Location
    Fairmont, West Virginia
    Posts
    4,866
    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=-

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •