|
-
Nov 28th, 2001, 06:52 AM
#1
Thread Starter
New Member
visual basic 6.0 question
I have a form with three text boxes and a command button. I have to write the instructions such that when the button is pressed the strings in txtBox1 and txtBox2 are concatenated and the results are displayed in txtOutput. Can you please show me how this is done?
Thank you
-
Nov 28th, 2001, 06:57 AM
#2
Conquistador
Private Sub Command1_Click()
Text3.Text = Text1 & Text2
End Sub
something like that?
-
Nov 28th, 2001, 06:58 AM
#3
Member
code:
txtbox3 = txtbox1.text + txtbox2.text
if they r numbers then
txtbox3 = val(txtbox1.text) + val(txtbox2.text)
-
Nov 28th, 2001, 07:08 AM
#4
Hyperactive Member
Don't listen to him.....
Originally posted by holy1
code:
txtbox3 = txtbox1.text + txtbox2.text
Don't concatenate strings with +, use & as Major da Silvy said. Then read my signature
-
Nov 28th, 2001, 11:28 AM
#5
Member
whats the harm in using "+" ?
-
Nov 28th, 2001, 12:00 PM
#6
Frenzied Member
For one, if you use Val() and +, it will add them not concatenate them.
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Nov 28th, 2001, 12:03 PM
#7
Member
i know that
didnt u read "IF THEY ARE NUMBERS THEN" USE VAL() else
dont use them
-
Nov 28th, 2001, 05:06 PM
#8
Frenzied Member
Yes, I did read that part and that was why I said what I said, if you use Val() and Text1 = 3 and Text2 = 3 then you would have 6 not 33. So you would be ADDING not CONCATENATING, so you would never use the Val() function with concatenation!
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Nov 28th, 2001, 05:27 PM
#9
Fanatic Member
Or like this if you happened to need a space between them
Code:
Private Sub Command1_Click()
Text3.Text = Text1 & " " & Text2
End Sub
JO
"I have not failed. I've just found 10,000 ways that won't work."
'Thomas Edison'
"If we knew what it was we were doing it wouldn't be called research, would it?"
'Albert Einstein'
VB6
-
Nov 28th, 2001, 05:47 PM
#10
Frenzied Member
i use
VB Code:
Private Sub Command1_Click()
Text3.Text = Text1.text & " " & Text2.text
End Sub
like JO does i think that is the best way to do it and the easyist
-
Nov 28th, 2001, 05:53 PM
#11
Frenzied Member
i use
VB Code:
Private Sub Command1_Click()
Text3.Text = Text1.text & " " & Text2.text
End Sub
like JO does i think that is the best way to do it and the easyist
-
Nov 29th, 2001, 03:02 AM
#12
Conquistador
Originally posted by holy1
i know that
didnt u read "IF THEY ARE NUMBERS THEN" USE VAL() else
dont use them
no one reads any more 
like motox posted same thing twice and it was already posted
-
Nov 29th, 2001, 06:28 AM
#13
Hyperactive Member
MSDN....
Originally posted by holy1
whats the harm in using "+" ?
MSDN says:
When you use the + operator, you may not be able to determine whether addition or string concatenation will occur. Use the & operator for concatenation to eliminate ambiguity and provide self-documenting code.
It prevents the dreaded "evil type coercion"
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
|