Results 1 to 25 of 25

Thread: text input

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2013
    Posts
    62

    text input

    i am new in ab6 . i need to read textbox input with button click with a textbox input message ..

    if textbox is entered 123dger4 and when i click button . there should be a message box like .. input is 123dger4

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: text input

    Code:
    Option Explicit
    
    Private Sub cmdInput_Click()
    Dim str As String
     str = InputBox("Enter info", "Input")
     If str = "123dger4" Then MsgBox ("Input is " & str)
    End Sub
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2013
    Posts
    62

    Re: text input

    If str = "123dger4" Then MsgBox ("Input is " & str)

    no no sir how come we know what user will enter text input

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: text input

    Two ways

    str = InputBox("Enter info", "Input")
    MsgBox ("Input is " & str)

    or

    MsgBox ("Input is " & InputBox("Enter info", "Input"))
    Last edited by jmsrickland; Jul 29th, 2014 at 10:09 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2013
    Posts
    62

    Re: text input

    i actually do not want to use inputbox . i need to use textbox .. if textbox has input, then button will work otherwise not

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: text input

    I would recommend against using str as a variable name STR() is a VB function

    Given the way the question is worded I can't tell if the poster is looking for an InputBox or an actual TextBox

    If it is referring to a textbox then the code would be something like
    Code:
    Private Sub cmdInput_Click()
        Msgbox Text1.Text
    End Sub

  7. #7
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: text input

    Quote Originally Posted by stiphen View Post
    If str = "123dger4" Then MsgBox ("Input is " & str)

    no no sir how come we know what user will enter text input

    If Text1.Text = "123dger4" Then
    MsgBox ("Input is " & Text1.Text)
    end if

  8. #8
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: text input

    Or what I think he wants...

    Code:
    Private Sub Command1_Click()
    MsgBox ("Input is " & Text1.Text)
    End Sub
    
    Private Sub Form_Load()
    Command1.Enabled = False
    End Sub
    
    Private Sub Text1_Change()
    If Text1.Text = "123dger4" Then Command1.Enabled = True Else Command1.Enabled = False
    End Sub

  9. #9
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: text input

    Well, I guess the original post wants

    Code:
    Option Explicit
    
    Private Sub cmdInput_Click()
    Dim sInput As String
     sInput = TextInfo.Text
      MsgBox ("Input is " & sInput)
    End Sub
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: text input

    Why would you dim a var then set it to the text property and then display the value of the var rather than just using the already existing text property like I showed in post #6?

    If a text box is being used then there is no need to define a var and assign it. The textbox is enough.

  11. #11
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: text input

    Quote Originally Posted by stiphen View Post
    i actually do not want to use inputbox . i need to use textbox .. if textbox has input, then button will work otherwise not

    Code:
    Private Sub cmdInput_Click()
    If Len(Text1.Text)>0 then
        Msgbox "Input is " & Text1.Text
    End If
    End Sub

  12. #12
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: text input

    Quote Originally Posted by stiphen View Post
    If str = "123dger4" Then MsgBox ("Input is " & str)

    no no sir how come we know what user will enter text input
    Quote Originally Posted by stiphen View Post
    i actually do not want to use inputbox . i need to use textbox .. if textbox has input, then button will work otherwise not
    I think my example in Post #8 would be the closest to what he wants.
    Last edited by Max187Boucher; Jul 29th, 2014 at 11:07 PM. Reason: forgot one quote

  13. #13
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: text input

    Quote Originally Posted by DataMiser View Post
    Why would you dim a var then set it to the text property and then display the value of the var rather than just using the already existing text property like I showed in post #6?
    So you mean like?

    Code:
      MsgBox ("Input is " & txtText1.Text)
    Referring to the varible is easier because if you have a huge amount of code using the value of the var all you need to do is change the initial input to the var example txtText1.Text whereas if you txtText.Text on each occasion and then decided you want to change it it would be a lot of work.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  14. #14
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: text input

    Whatever OP wants he does not want "123dger4" to be tested then do something if true. He made that clear in post #3


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  15. #15
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: text input

    Quote Originally Posted by Max187Boucher View Post
    I think my example in Post #8 would be the closest to what he wants.
    Actually no, it seems like he just wants a msgbox to pop up that shows what was entered into the text box when a button is clicked but only when the button is clicked. Post #11 should be what he seems to want.

    He definitely does not want it to only be enabled when a specific string is entered.

    Alternately one could add code to the change event that would enable/disable the button based on there being at least one character in the text box but would still need the code in the button click event similar to post #6

    Referring to the varible is easier because if you have a huge amount of code using the value of the var all you need to do is change the initial input to the var example txtText1.Text whereas if you txtText.Text on each occasion and then decided you want to change it it would be a lot of work.
    In some cases that would be true but not here. Think about it, you are adding two lines of code that are not needed and you still have to reference the textbox to get the value.
    Last edited by DataMiser; Jul 30th, 2014 at 12:44 AM.

  16. #16

    Thread Starter
    Member
    Join Date
    Nov 2013
    Posts
    62

    Re: text input

    sorry ! after working on the same .. i just need some changes ..

    ist i need to set the values of numbers like

    1= ab
    2=cf
    3=hg
    4=kl
    5=tr
    6=oi
    7=vd
    8= mn
    9=fd
    0=pp

    and when user enter in textbox 579 and after cmdbutton is clicked msgbox should be "trvdfd" and if textbox is empty . and if cmdbtn is click msgbox textbox is empty

  17. #17
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: text input

    So you want if a user enters a particular it enters the equivalent letters in to the textbox?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  18. #18

    Thread Starter
    Member
    Join Date
    Nov 2013
    Posts
    62

    Re: text input

    no if a user enter 579 in textbox [only numbers] , after cmdbutton click message box should show "trvdfd" but not 579

    that is what i said ist i need to set the values of numbers 0-9 like in #16 .. need assistance plz

  19. #19
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: text input

    Quote Originally Posted by stiphen View Post
    no if a user enter 579 in textbox [only numbers] , after cmdbutton click message box should show "trvdfd" but not 579

    that is what i said ist i need to set the values of numbers 0-9 like in #16 .. need assistance plz
    Code:
    Option Explicit
    Dim Letters As String
    
    Private Sub Command1_Click()
     MsgBox (Letters)
    End Sub
    
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
     Case 48
       Letters = Letters & "pp"
     Case 49
      Letters = Letters & "ab"
     Case 50
       Letters = Letters & "cf"
     Case 51
       Letters = Letters & "hg"
     Case 52
       Letters = Letters & "kl"
     Case 53
       Letters = Letters & "tr"
     Case 54
       Letters = Letters & "oi"
     Case 55
       Letters = Letters & "vd"
     Case 56
       Letters = Letters & "mn"
     Case 57
       Letters = Letters & "fd"
     End Select
    End Sub
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  20. #20
    Hyperactive Member
    Join Date
    Jun 2014
    Location
    Lahore, Pakistan
    Posts
    450

    Re: text input

    Quote Originally Posted by stiphen View Post
    no if a user enter 579 in textbox [only numbers] , after cmdbutton click message box should show "trvdfd" but not 579

    that is what i said ist i need to set the values of numbers 0-9 like in #16 .. need assistance plz
    Code:
    Private Sub Command1_Click()
    Select Case Text1.Text
        Case 1:
            MsgBox "ab"
        Case 2:
            MsgBox "cf"
        Case 3:
            MsgBox "hg"
    End Select
    End Sub
    Use this or What Nightwalker suggest.What ever you can easily understand

  21. #21
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: text input

    Quote Originally Posted by DataMiser View Post
    Actually no, it seems like he just wants a msgbox to pop up that shows what was entered into the text box when a button is clicked but only when the button is clicked. Post #11 should be what he seems to want.

    He definitely does not want it to only be enabled when a specific string is entered.

    Alternately one could add code to the change event that would enable/disable the button based on there being at least one character in the text box but would still need the code in the button click event similar to post #6

    In some cases that would be true but not here. Think about it, you are adding two lines of code that are not needed and you still have to reference the textbox to get the value.
    We were not even close to what he wanted, thats due to OP not giving enough information.
    I don't understand why post #16 wasn't post #1.

  22. #22
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: text input

    To feed textbox with letters by means reading a look up table you have to make it like someone type. So the caret must follow every input, and if a backspace pressed then you have to go back. For the handling of enter there is nothing to say....
    What I didn't saw yet is the two buffer system, one for display the letters and one that holds numbers. Why we need two buffers? Because one buffer is the input (so we delete from there) and the other is the displayed..string. We can replace the second string with a function to regenerate, the "generator".
    If we don't want to display caret, then we don' have to stick to a textbox and we can use label...and take the input from form keydown or better keypress event. The function to display, the "generator" can have the logic to enable the button, because it is in the clean place, after the collection of the right keystrokes.
    Using vb6 we go beyond ordinary programming, and we must understand what event is,and the timing, which event is before other, and how to block events. (that isn't a programming, is a brain game...)

  23. #23
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: text input

    Quote Originally Posted by Max187Boucher View Post
    We were not even close to what he wanted, thats due to OP not giving enough information.
    I don't understand why post #16 wasn't post #1.
    Most likely the Original Poster was confused about what he/she

    wanted to do.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  24. #24
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: text input

    Post #16 in no way resembles post #1, completely different.

    First it is "I want what is entered in the text box to be displayed in a msgbox" Then it is like "No I don't want that I want the user to enter numbers and I want to display characters based on pairs on numbers even though the example shows an odd number of digits together with text between them that is not even close to what I want"

    At this point I will not bother to guess any more, seems a waste of time to follow this thread.


  25. #25
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: text input

    Quote Originally Posted by DataMiser View Post
    Post #16 in no way resembles post #1, completely different.

    First it is "I want what is entered in the text box to be displayed in a msgbox" Then it is like "No I don't want that I want the user to enter numbers and I want to display characters based on pairs on numbers even though the example shows an odd number of digits together with text between them that is not even close to what I want"

    At this point I will not bother to guess any more, seems a waste of time to follow this thread.

    That is why it is important to have a clear idea of what you want to accomplish before asking for help achieving the goal.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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