473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

how to clear the value stored in a temporary variable

103 100+
Want to change the value stored in the bold, it's a code to calculate the payroll.

Expand|Select|Wrap|Line Numbers
  1. If txttr.Text = "" Then
  2.   Form2.txttamt.Text = ""
  3.   MsgBox "enter the tax rate", vbOKOnly, "ERROR"
  4.   'Form2.txttamt.Text = ""
  5.   cbostate.SetFocus
  6. Else
  7.   res1 = txttr.Text / 100
  8. End If
  9. rs.Open "Select  * From empdetail Where name =  '" & ListView1.SelectedItem & "' ", conn, adOpenStatic, adLockOptimistic
  10. a = rs!whours
  11. txtoh.Text = Val(txthrs.Text - a)
  12. txtotamt.Text = Val(Form2.txtoh * Form2.txtotrt)
  13. res = Val(Form2.txthrs.Text * Form2.txtrate.Text)
  14. Form2.txttamt.Text = Val(res * res1)
  15. Form2.txtgros.Text = Val((txthrs.Text * txtrate.Text) - (txttamt.Text))
  16. 'str1 = txttr.Text
  17. Form2.txtnsal.Text = Val(Form2.txtgros.Text - Form2.txttamt)
  18. rs.Close
  19. Set rs = Nothing
Solution to this please, thanks in advance.
Dec 19 '07 #1
9 5355
jamesd0142
469 256MB
Am i understanding this correctly...

variable = "value"

changes the value stored in the variable.

So what can you just do that?
Dec 19 '07 #2
Vbbeginner07
103 100+
Am i understanding this correctly...

variable = "value"

changes the value stored in the variable.

So what can you just do that?
It stores a value at the first computation then we are going in for another computation of emp. salary.

In the meanwhile, res1 stores the value of the first computation. I have to change the res1 to zero for next computation.

I think you understood it.
Dec 19 '07 #3
debasisdas
8,127 Expert 4TB
You can assign any other value to the variable you want.

BTW what is a temporary variable ?
Dec 19 '07 #4
Killer42
8,435 Expert 8TB
Probably the best thing to do would be to set it to zero when you don't want the value. In other words...

If textbox not valid
Set to zero
Else
Do calculation
End If

Any value you place in the variable will replace what's already there, so you don't need to clear it before using it again.
Dec 19 '07 #5
Vbbeginner07
103 100+
Probably the best thing to do would be to set it to zero when you don't want the value. In other words...

If textbox not valid
Set to zero
Else
Do calculation
End If

Any value you place in the variable will replace what's already there, so you don't need to clear it before using it again.
no actually the value for previous calculation is stored in "res1"

i have done the same code
If textbox not valid
Set to zero
Else
Do calculation
End If


but that is not working bcos res1 is not a built in variable but a user created so it cant be assigned to 0

Do check my code In #1
Dec 20 '07 #6
Vbbeginner07
103 100+
You can assign any other value to the variable you want.

BTW what is a temporary variable ?
i meant that as a variable that store the mid level calculations.
hope u have gone thru my code,if not please go thru and suggEST A soln.

thanks in advance
Dec 20 '07 #7
QVeen72
1,445 Expert 1GB
Hi,

Before IF Condition, Assign zero to res1 :

Expand|Select|Wrap|Line Numbers
  1. res1 = 0
  2. If txttr.Text = "" Then
  3.   Form2.txttamt.Text = ""
  4.   MsgBox "enter the tax rate", vbOKOnly, "ERROR"
  5.   'Form2.txttamt.Text = ""
  6.   cbostate.SetFocus
  7. Else
  8.   res1 = txttr.Text / 100
  9. End If
  10.  
By the way, what is "User Created Variable"...?

Regards
Veena
Dec 20 '07 #8
Killer42
8,435 Expert 8TB
...but that is not working bcos res1 is not a built in variable but a user created so it cant be assigned to 0
That sentence simply does not make any sense. I think we need to have a bit of a discussion about variable scope and so on.
Dec 20 '07 #9
Vbbeginner07
103 100+
That sentence simply does not make any sense. I think we need to have a bit of a discussion about variable scope and so on.
yeah,let'z start killer!!!!
Dec 21 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
1
by: Serge Shimanovsky | last post by:
Hi, I have a situation where I need to clear the event sinks from an event. But let's say I don't know which methods (by name, I mean) signed up for that event. I do have a control with...
19
by: JKop | last post by:
When I compile and run the following on my system: #include <iostream> static int hello = 78; int ReturnValue(void) {
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
7
by: Jamie Julius | last post by:
Consider the following struct: struct TestStruct { public int a, b, c; public TestStruct(int a, int b, int c) { this.a = a;
4
by: Alex D. | last post by:
Hi. I have a TreeView stored in a session variable...is ok...problem is when I use Nodes.Clear() then my session variable that holds the TreeView is also emptied! Is this behavior by design or...
6
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has...
12
by: dave_dp | last post by:
Hi, I have just started learning C++ language.. I've read much even tried to understand the way standard says but still can't get the grasp of that concept. When parameters are passed/returned...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.