Link to home
Start Free TrialLog in
Avatar of aiman_alnasir
aiman_alnasir

asked on

Is it possible to have one textbox reading three input integer from the user?

Is it possible to have one textbox reading three input integer from the user instead of asking three times using inputbox?
Dim Show1, Show2, Show3 As String
        Show1 = InputBox("Enter CID Number: ")
        a = Show1
        Show2 = InputBox("Enter DID Number: ")
        b = Show2
        Show3 = InputBox("Enter TID Number: ")
        c = Show3
 
        dbcmd.Connection = con
 
dbcmd.CommandText = "Select * From table Where CID = " & a & " and DID = " & b & " and TID = " & c

Open in new window

Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Yes, you can.
You can separate the values by something (empty space, ";", ",", etc) and then split the three values.
I think it's a good answer for 20 points :)
Avatar of aiman_alnasir
aiman_alnasir

ASKER

How ?

I want to read three value from one textbox? Can you provide me with the code !

Hello aiman_alnasir,

LIke this:

Regards,
Chris
Sub splitter()
Dim strShow As Variant, a, b, c As String
        strshow = Split(InputBox("Enter CID Number: ") & ",", ",")
        If UBound(strshow) = 3 Then
            a = strshow(0)
            b = strshow(1)
            c = strshow(2)
        End If 
End Sub

Open in new window

Ah

I've just looked at your membership aiman_alnasir.  I asumed you were a limited member with limited points.  I understand the comment now as yes 20 points out of an unlimited stock is not a lot.

Chris
>>  I asumed you were a limited member with limited points
I didn't have VB to test the code, so I just dropped a comment. But 20 point is also too low for a code snippet :)
@chris_bottomley,
Just a comment about your variable declaration: if is it's for VB6 or VBA, the "a" and "b" it will assume as Variant and not as String. You can only do that in .NET versions and you "old" VB way you need to declare individually.
It's not a problem, as you know, but just to clarify. :)
Believe it or not! I dont know anything about the points that you are talking about. I dont know if there is limited point for some member or not && however, I will look at it.  O.k, about my concern, please see my comments below;
        Dim strShow As Object
        Dim a, b, c As String
        'Are you sure it is reading from textbox
        strShow = Split(InputBox("Enter CID Number: ") & ",", ",")
'This code is it after sql statment or before! On both it's not working       
If UBound(strShow) = 3 Then
            a = strShow(0)
            b = strShow(1)
            c = strShow(2)
        End If

Open in new window

The script certainly works I tested it albeit in VBA.  IT does a sanity check to ensure three datums with comma seperators.

As for points, take a look around, you own previous posts were 500 to 125 as I recall.  The point is they are yours to use and as a premium member you have an unlimited supply albeit each question is limited to 500 tops.

How many points you assign depends on how soon you want an answer, how many people may be interested to post alternatives and how hard it is.  I have never seen a premium member post 20 points myself although limited members do since sometimes that is as many points as they have.  The assignment of points is however very personal so do as you wish but take a look at some of the questions, the answers and the number of points assigned and perhaps it will help you get appropriate help.

Are you sure you are entering three parameters ... and I have corrected the observer declaration error below.

Note if you use a setting for option base in your code can you let me know as I have assumed the default value of 0

Chris
Sub splitter()
Dim strShow As Variant
Dim a As String
Dim b As String
Dim c As String
        strshow = Split(InputBox("Enter CID Number: ") & ",", ",")
        If UBound(strshow) = 3 Then
            a = strshow(0)
            b = strshow(1)
            c = strshow(2)
        End If 
End Sub

Open in new window

It is reading from inputbox and I ONLY need to read from the textbox1.text ONLY.
I want the textbox1.text asked me;
1- Enter CID Number:       (If I press Button1 it should ask me to Enter DID Number: and so on ..ect) than I want to check the three entry if it is exist on the database or not?

'I will do the ckecking part from the databse

myform.jpg
Good luck with that, in your original question you started with an input box and I have maintained that in the response.

Chris
I know it is not easy to do so. This is why I asked if it is possible to have one textbox reading three input integer from the user instead of asking three times by using inputbox? I don't know what do you mean by "started with an input box and I have maintained that in the response".
I don't think there is a solution.
There is a solution as given by paulino, with the sample from me.  Yes the sample for ease used the input box, but for 20 points and no worked example what do you want?

All you have to do is work the split into your form code replacing the input box with the text box returned string.

It is easy to do as described and as implied by your points assignment..

Chris

ASKER CERTIFIED SOLUTION
Avatar of barrislb
barrislb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
modus_operandi / aiman_alnasir

I'm not sure why the post but I assume a request has been made to delete the Q.  In this case I would say that barrislb:at post 24888865 has the most relevant and complete post that answers the question.

Note the question was to take three values and input them in one pass, the post by barrislb does exactly that and I see no response from aiman_alnasir to indicate a problem.

I would be surprised at an action that closes the question and refunds the points as I feel the experts involved have entered relevant information that meets the original question.

Chris
Thanks, Chris, for your backing...in your previous post. :- )