-
Jul 29th, 2014, 09:31 PM
#1
Thread Starter
Member
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
-
Jul 29th, 2014, 09:50 PM
#2
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
-
Jul 29th, 2014, 10:03 PM
#3
Thread Starter
Member
Re: text input
If str = "123dger4" Then MsgBox ("Input is " & str)
no no sir how come we know what user will enter text input
-
Jul 29th, 2014, 10:05 PM
#4
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.
-
Jul 29th, 2014, 10:33 PM
#5
Thread Starter
Member
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
-
Jul 29th, 2014, 10:34 PM
#6
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
-
Jul 29th, 2014, 10:37 PM
#7
Re: text input
Originally Posted by stiphen
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
-
Jul 29th, 2014, 10:40 PM
#8
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
-
Jul 29th, 2014, 10:41 PM
#9
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
-
Jul 29th, 2014, 10:57 PM
#10
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.
-
Jul 29th, 2014, 11:01 PM
#11
Re: text input
Originally Posted by stiphen
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
-
Jul 29th, 2014, 11:05 PM
#12
Re: text input
Originally Posted by stiphen
If str = "123dger4" Then MsgBox ("Input is " & str)
no no sir how come we know what user will enter text input
Originally Posted by stiphen
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
-
Jul 29th, 2014, 11:12 PM
#13
Re: text input
Originally Posted by DataMiser
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
-
Jul 29th, 2014, 11:52 PM
#14
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.
-
Jul 30th, 2014, 12:39 AM
#15
Re: text input
Originally Posted by Max187Boucher
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.
-
Jul 30th, 2014, 01:23 AM
#16
Thread Starter
Member
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
-
Jul 30th, 2014, 02:07 AM
#17
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
-
Jul 30th, 2014, 02:38 AM
#18
Thread Starter
Member
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
-
Jul 30th, 2014, 03:06 AM
#19
Re: text input
Originally Posted by stiphen
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
-
Jul 30th, 2014, 03:08 AM
#20
Hyperactive Member
Re: text input
Originally Posted by stiphen
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
-
Jul 30th, 2014, 07:30 AM
#21
Re: text input
Originally Posted by DataMiser
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.
-
Jul 30th, 2014, 06:40 PM
#22
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...)
-
Jul 30th, 2014, 08:40 PM
#23
Re: text input
Originally Posted by Max187Boucher
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
-
Jul 30th, 2014, 09:18 PM
#24
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.
-
Jul 30th, 2014, 10:10 PM
#25
Re: text input
Originally Posted by DataMiser
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|