|
-
Dec 26th, 2005, 07:47 AM
#1
Thread Starter
Lively Member
Still Lurking at TextBox calculations Problem... Plz Help:(
Dear mentors,
This should happen only once when i add something in texbox. But it pluses again values of textbox1.text + textbox2 when i modify a record.
VB Code:
Private Sub textbox2_KeyPress(KeyAscii As Integer)
If keyascii = 13 then
textbox3= val(textbox1.text) + val (textbox2.text)
End IF
End IF

I want: the Result remain stable, if i add something in textbox1 it add in Result and when i delete any value which is already in textbox 1 or 2 it effects on result during modification.
plz help rapid..
thanx inadvance
Last edited by Plucky; Dec 26th, 2005 at 07:53 AM.
-
Dec 26th, 2005, 01:33 PM
#2
Thread Starter
Lively Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
hi folks, it is a second day, but still i'm waiting for response from any one who could be enough kind...
-
Dec 26th, 2005, 02:00 PM
#3
Thread Starter
Lively Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
Lets take it this way.. if you are not understanding what i wanted to ask you...
I have 3 texboxes on my form. What I want I tell you in detail.
When I reached on text2.text after entering any value in it I press Enter,
If keyascii = 13 then
Txtresult.text = val(text1.text) + val(text2.text)
Endif
This code added value 1 in to value 2 and results shows in txtresult.text. Well it is working, but when I again come on text2.text and without any change in value I only press Enter Key (keyascii = 13) same value which is already in text2.text again added in txtresult.text. This addition go on and on each time when I press enter key in text2.text.
I wish it should only add that value which I change or write in text2.text instead of by pressing Enter Key it added same value into the result again. This is problem, please help me to solve it.
-
Dec 26th, 2005, 02:41 PM
#4
Frenzied Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
Plucky:
Well, it is the Christmas Holiday weekend and so there are not a lot of people hanging out in the forum.
Private Sub textbox2_KeyPress(KeyAscii As Integer)
If keyascii = 13 then
textbox3= val(textbox1.text) + val (textbox2.text)
End IF
End IF
To start with you need to change the last End If to End Sub.
Also in your third posting you say "txtresult.text, but that is not in your code?
Did you change textbox3.text to txtresult.text?
It seems to work when I try it.
I put 50 in textbox1 and 25 in textbox2 and when I press enter I get 75 in textbox 3. If I go back and delete 50 from textbox 1 and enter 100 in textbox 1 then when I put the cursor in textbox2 and press enter I get 125 in textbox3.
You must have some other code that you have not posted that is effecting it.
-
Dec 26th, 2005, 10:42 PM
#5
Thread Starter
Lively Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
Mr. AIS4U
Thanx for your response, but as you told me that you try it on your screen. I also tried it like you did, it is working fine. But i'm saving data in MS Access Database.
I think you did'nt try it, please just press Enter key (keyascii=13) in text box 2 or 1 and look at the result. on key press event it simply added the same value which is already in textbox 1 or 2 into the result.
It was my typing mistake, i have textbox3.text instead of textresult.text..
help, plz
-
Dec 27th, 2005, 12:20 AM
#6
Hyperactive Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
 Originally Posted by Plucky
Mr. AIS4U
Thanx for your response, but as you told me that you try it on your screen. I also tried it like you did, it is working fine. But i'm saving data in MS Access Database.
I think you did'nt try it, please just press Enter key (keyascii=13) in text box 2 or 1 and look at the result. on key press event it simply added the same value which is already in textbox 1 or 2 into the result.
It was my typing mistake, i have textbox3.text instead of textresult.text..
help, plz
why dont you setting some flag to skip after first attempt. means,
try this
If flag = 0 Then
If KeyAscii = 13 Then
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End If
flag = 1
End If
here flag is a simple variable and declare it in general and each text change(text1 and text2) event change the value of flag=0
Last edited by sajankk; Dec 27th, 2005 at 12:25 AM.
-
Dec 28th, 2005, 01:41 AM
#7
Thread Starter
Lively Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
Mr. sajankk
Thanx for help, but this flag is working in between only 2 textboxes like i wrote under:
If flag = 0 Then
If KeyAscii = 13 Then
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End If
flag = 1
End If
-------------------------
Not working like this:
If flag = 0 Then
If KeyAscii = 13 Then
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
Text3.Text = val(Text3.Text) + val(text2.text)
Text7.Text = val(Text7.Text) - val(Text8.text)
End If
flag = 1
End If
------------
Plz help
-
Dec 28th, 2005, 02:30 AM
#8
Hyperactive Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
when u want to do the calculation. keypress event of text2 or what ?
saj
-
Dec 28th, 2005, 02:34 AM
#9
Thread Starter
Lively Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
Mr. Sajankk
Yes, i want calculation on text2.text keypress even.
-
Dec 28th, 2005, 02:52 AM
#10
Hyperactive Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
 Originally Posted by Plucky
Mr. Sajankk
Yes, i want calculation on text2.text keypress even.
what is not working there. can u brief
-
Dec 28th, 2005, 02:59 AM
#11
Thread Starter
Lively Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
ok, Mr. Sajan
It is not working on more than 2 or 3 calculation at same time.
When i change value in Text1.Text it effects only once in single additoin which is like this, detail is under with my orignal textbox names:
-----------------
Private Sub txtgypconop1_KeyPress(KeyAscii As Integer)
If flag = 0 Then
If KeyAscii = 13 Then
cemprodop1 = Val(txtckconop1) + Val(txtgypconop1.Text)
cemprodop1.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
txtcemstockop.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
txtmtdcemprodop1.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
ytdcemprodop1.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
End If
flag = 1
ckconsr.SetFocus
End If
===============
Help, me.. plz
-
Dec 28th, 2005, 03:40 AM
#12
Hyperactive Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
its working nice with me i feel,
did u changed the flag=0, in the textchange even of these 2 text boxes,
txtckconop1.Text
txtgypconop1.Text
saj
-
Dec 28th, 2005, 05:38 AM
#13
Thread Starter
Lively Member
Re: Still Lurking at TextBox calculations Problem... Plz Help:(
Mr. Sajankk
You are right it is working between
txtckstockop.text = val(txtckconop1.text) + val(txtgypconop1.text)
but not working as
cemprodop1 = Val(txtckconop1) + Val(txtgypconop1.Text)
cemprodop1.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
txtcemstockop.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
txtmtdcemprodop1.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
ytdcemprodop1.Text = Val(txtckconop1.Text) + Val(txtgypconop1.Text)
help help help help help help help help help help help help help help help help help
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
|