Results 1 to 10 of 10

Thread: How can I track the button clicks in Inputbox function?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    Hyderabad,India
    Posts
    131

    How can I track the button clicks in Inputbox function?

    I want to track the button clicks in my inputbox function. I want to perform one action when I press OK and I want to perform another when I press Cancel button. Is there any way to do it?

  2. #2
    Hyperactive Member Dinz's Avatar
    Join Date
    Jan 2002
    Posts
    359
    the one way is inputbox returns value typed in text box in as a string when u press ok and blank strin when u press cancel....so u can check
    temp=inputbox("Enter ur Name")

    if not temp="" then
    msgbox "OK"
    else
    msgbox "Cancel"
    end if
    !!!NobodyisPerfect......IamNOBODY!!!
    How's your wife and my kids?.....

    Never argue with an idiot. They drag you down to their level then beat you with experience!

    Child says : Mummy mummy, can i play with grandpa ?
    Mum says : NO, you have already dug him up twice.

    Galahtec The VB Forum

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim s As String
    3.     s = InputBox("Give!")
    4.    
    5.     If StrPtr(s) = 0 Then
    6.           MsgBox "Cancel was pressed"
    7.     Else
    8.           MsgBox "Ok was pressed"
    9.     End If
    10. End Sub
    -= a peet post =-

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Greetings, bug boy.

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by Dinz
    the one way is inputbox returns value typed in text box in as a string when u press ok and blank strin when u press cancel....so u can check
    temp=inputbox("Enter ur Name")

    if not temp="" then
    msgbox "OK"
    else
    msgbox "Cancel"
    end if
    If the user presses OK without typing anything, u still get "" .... ?
    -= a peet post =-

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by mendhak
    Greetings, bug boy.
    hey FoxyFrog !
    -= a peet post =-

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    What's strptr() ?

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    MSN

    Strings in Visual Basic are stored as BSTR's. If you use the VarPtr on a variable of type String, you will get the address of the BSTR, which is a pointer to a pointer of the string. To get the address of the string buffer itself, you need to use the StrPtr function. This function returns the address of the first character of the string. Take into account that Strings are stored as UNICODE in Visual Basic.

    To get the address of the first character of a String, pass the String variable to the StrPtr function.

    Example:



    Dim lngCharAddress as Long
    Dim strMyVariable as String
    strMyVariable = "Some String"
    lngCharAddress = StrPtr(strMyVariable)
    my english is no good, so I'll leave the explanation to MSN

    This is why my sample will work. If Ok is pressed without the user adding any data to the input field, StrPtr will still return a value, because the variable has been assigned the "" value, wheras if the user click cancel, the StrPtr will return 0

    -= a peet post =-

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I semiunderstood that. So a half hearted thank you.

  10. #10
    Hyperactive Member Dinz's Avatar
    Join Date
    Jan 2002
    Posts
    359
    wow...this was an amazing information......hats off peet
    !!!NobodyisPerfect......IamNOBODY!!!
    How's your wife and my kids?.....

    Never argue with an idiot. They drag you down to their level then beat you with experience!

    Child says : Mummy mummy, can i play with grandpa ?
    Mum says : NO, you have already dug him up twice.

    Galahtec The VB Forum

Posting Permissions

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



Click Here to Expand Forum to Full Width