|
-
May 7th, 2000, 12:17 AM
#1
Thread Starter
Junior Member
im trying to get vb to add up a list of fig held in text boxs
eg
a = text1.text
b = text2.text
c = a + b
text3.text = c
with 10 in both text1 and text2 i was hopping for 20 in text3 but i am getting 1010 can anybody please help.
Thanks
Dave
-
May 7th, 2000, 12:36 AM
#2
transcendental analytic
Either use val function to get a numeric expression or declare your variables as integers
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 7th, 2000, 12:40 AM
#3
Member
don't ask me why this works.
[code]
Private Sub Command1_Click()
Text3.Text = (Text2) * (Text1) / (Text1) + (Text1)
End Sub
Charlie Staton
14 y/o
I don't smoke, I don't drink, and I don't assosciate with pokemon.
-
May 7th, 2000, 12:47 AM
#4
Dave ~
I'm new to this as well and learning on my own too. This is a great place for advice! Super helpful people here!
I created a quick form and tried this out so it should work for you.
On the form I created three text boxes and one command button, named cmdAdd. Hope this helps you! 
Code:
Private Sub cmdAdd_Click()
'Declare numbers you wish to add as Integers.
Dim intA As Integer, intB As Integer
intA = txtA.Text
intB = txtB.Text
txtC.Text = intA + intB
End Sub
-
May 7th, 2000, 12:50 AM
#5
Hello,
You could also use this:
Code:
a = Cint(text1.text) ' change to an integer
b = Cint(text2.text)
c = a + b
text3.text = c
Check the help files for Cint, and see the other types you can change to.
Hope this helps,
-
May 7th, 2000, 01:16 AM
#6
transcendental analytic
VAL(expression) gives you any values from strings
CINT(expression) Rounds your value to the nearest whole
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 7th, 2000, 01:41 AM
#7
Addicted Member
Just to give the example of Val...
Private Sub cmdAdd_Click()
Text3.Text = Val(Text1.Text) + (Text2.Text)
End Sub
The Val converts the string to a numeric value
GRAHAM
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
|