|
-
Dec 2nd, 2008, 10:40 AM
#1
Thread Starter
Lively Member
Text Box Calculations
Ok I have 3 text boxed
Text1
Text2
Text3
In each Text box I have numbers
Text1.Text = 30
Text2.Text = 8
Text3.Text = 25
I have dimmed Solution to hold the calculation. I also have dimmed Text1, 2, & 3 but in this example Im just trying to point out my problem.
My formula is set like this
If Text2 < Text3 then
Solution = Text3 - Text2 - 1
The only time that the solution comes out correct, is when Im using double digits.
This comes out correct-
Text1.Text = 30
Text2.Text = 08
Text3.Text = 25
This doesn't-
Text1.Text = 30
Text2.Text = 8
Text3.Text = 25
Does anyone know what the problem could be? Any help is greatly appreciated.
-
Dec 2nd, 2008, 10:57 AM
#2
Member
Re: Text Box Calculations
-
Dec 2nd, 2008, 11:08 AM
#3
Thread Starter
Lively Member
Re: Text Box Calculations
-
Dec 2nd, 2008, 11:24 AM
#4
Junior Member
Re: Text Box Calculations
vb Code:
Private Sub Command1_Click()
Dim txt1 As Integer
Dim txt2 As Integer
Dim txt3 As Integer
txt1 = text1.Text
txt2 = text2.Text
txt3 = text3.Text
If txt2 < txt3 Then
Label1.Caption = txt3 - txt2 - 1
End If
End Sub
Here this worked. I allready tried it hope it helps.
-
Dec 2nd, 2008, 11:57 AM
#5
Thread Starter
Lively Member
Re: Text Box Calculations
I need to have the information stored in memory because it is called in multiple places and having it stored in a label can sometimes cause errors. Here is my code-
vb Code:
Private Sub cmdcalculate_Click() 'The Paremeters set for each value Dimmed on Form Load ArrearsDNM = txtarrearsdnm.Text ArrearsBC = txtarrearsbc.Text ArrearsDate = txtarrearsdate.Text ArrearsORP = txtarrearsorp.Text ArrearsOF = txtarrearsof.Text ArrearsNRP = txtarrearsnrp.Text ArrearsNF = txtarrearsnf.Text
Last edited by UnKnOwNCoDe; Dec 2nd, 2008 at 12:16 PM.
-
Dec 2nd, 2008, 11:59 AM
#6
Junior Member
Re: Text Box Calculations
i just used the label to verify the calculation. thats just how i got it to work.
-
Dec 2nd, 2008, 12:07 PM
#7
Re: Text Box Calculations
You have to conver the text to a number in order to perform any math functions.
Code:
If Val(Text2.Text) =< Val(Text3.Text Then
-
Dec 2nd, 2008, 12:10 PM
#8
Hyperactive Member
Re: Text Box Calculations
 Originally Posted by UnKnOwNCoDe
Ok I have 3 text boxed
Text1
Text2
Text3
In each Text box I have numbers
Text1.Text = 30
Text2.Text = 8
Text3.Text = 25
I have dimmed Solution to hold the calculation. I also have dimmed Text1, 2, & 3 but in this example Im just trying to point out my problem.
My formula is set like this
If Text2 < Text3 then
Solution = Text3 - Text2 - 1
The only time that the solution comes out correct, is when Im using double digits.
This comes out correct-
Text1.Text = 30
Text2.Text = 08
Text3.Text = 25
This doesn't-
Text1.Text = 30
Text2.Text = 8
Text3.Text = 25
Does anyone know what the problem could be? Any help is greatly appreciated.
i dont know.. if this correct..
Code:
If Val (Text2.Text) < val (Text3.Text) then
Solution = Val(Text2.Text) - Val(Text3.Text) -1
"More Heads are Better than One"
-
Dec 2nd, 2008, 12:14 PM
#9
Thread Starter
Lively Member
Re: Text Box Calculations
Ah ok. Thanks a lot!
I updated this portion
VbCode Code:
ArrearsDNM = Val(txtarrearsdnm.Text)
ArrearsBC = Val(txtarrearsbc.Text)
ArrearsDate = Val(txtarrearsdate.Text)
ArrearsORP = Val(txtarrearsorp.Text)
ArrearsOF = Val(txtarrearsof.Text)
ArrearsNRP = Val(txtarrearsnrp.Text)
ArrearsNF = Val(txtarrearsnf.Text)
I didnt change this but it appears to be working correctly.
VbCode Code:
If ArrearsBC > ArrearsDate Then
-
Dec 2nd, 2008, 02:10 PM
#10
Re: Text Box Calculations
How did you declare your variables?
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
|