Re: Text Box Calculations
Re: Text Box Calculations
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.
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
Re: Text Box Calculations
i just used the label to verify the calculation. thats just how i got it to work.
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
Re: Text Box Calculations
Quote:
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
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
Re: Text Box Calculations
How did you declare your variables?