Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 06, 2012 07:01 PM by infernocy
Member
35 Points
67 Posts
Feb 06, 2012 05:56 PM|LINK
i have this code in vb and i want to know how to make it to add decimal points
Dim a, b As Integer a = CSng(TextBox1.Text) b = CSng(TextBox2.Text) Dim result As Single result = a + b Lb_sum.Text = result
for example if i add 4.2 + 4.4 its show 8 instaid of 8.6
Thanks for all the help -
Participant
1292 Points
207 Posts
Feb 06, 2012 06:53 PM|LINK
You need to create the variables as Single not Integer. Then it should work just fine.
Dim a As Single Dim b As Single Dim result As Single a = CSng(TextBox1.Text) b = CSng(TextBox2.Text) result = a + b Lb_sum.Text = result
Feb 06, 2012 07:01 PM|LINK
yea it does thanks
infernocy
Member
35 Points
67 Posts
addition with decimal points
Feb 06, 2012 05:56 PM|LINK
i have this code in vb and i want to know how to make it to add decimal points
Dim a, b As Integer
a = CSng(TextBox1.Text)
b = CSng(TextBox2.Text)
Dim result As Single
result = a + b
Lb_sum.Text = result
for example if i add 4.2 + 4.4 its show 8 instaid of 8.6
Thanks for all the help -
ksqcoder
Participant
1292 Points
207 Posts
Re: addition with decimal points
Feb 06, 2012 06:53 PM|LINK
You need to create the variables as Single not Integer. Then it should work just fine.
Dim a As Single
Dim b As Single
Dim result As Single
a = CSng(TextBox1.Text)
b = CSng(TextBox2.Text)
result = a + b
Lb_sum.Text = result
infernocy
Member
35 Points
67 Posts
Re: addition with decimal points
Feb 06, 2012 07:01 PM|LINK
yea it does thanks