|
-
Oct 21st, 2000, 10:42 AM
#1
Thread Starter
New Member
I am trying to add the number i have got in a textbox to a number in my database. Somone gave me this code but it does not seem to work 
Dim mynewnumber As Integer
mynewnumber = myoldnumber + Text1.Text
Private Sub Command1_Click()
Data1.Recordset.Edit
Data1.recordest.score = myoldnumber
Text1.Text = mynewnumber
Data1.Recordset.score.myoldnumber = mynewnumber
Data1.recordest.Update
End Sub
Please can u help.
later mike
-
Oct 21st, 2000, 11:02 AM
#2
Lively Member
Originally posted by baynham
I am trying to add the number i have got in a textbox to a number in my database. Somone gave me this code but it does not seem to work 
Dim mynewnumber As Integer
mynewnumber = myoldnumber + Text1.Text
Private Sub Command1_Click()
Data1.Recordset.Edit
Data1.recordest.score = myoldnumber
Text1.Text = mynewnumber
Data1.Recordset.score.myoldnumber = mynewnumber
Data1.recordest.Update
End Sub
Please can u help.
later mike
You are trying to force types, sometimes it works, sometimes it doesn't to be sure that it works use the formal syntax:
Dim mynewnumber As Integer
Dim myoldnumber as Integer
mynewnumber = myoldnumber + Val(Trim(Text1.Text))
The Val function should trim the text string of leading blanks, but it doesn't take much effort to trim it.
Hunter
-
Oct 21st, 2000, 03:49 PM
#3
_______
<?>
If you are performing math on textbox data, you have to remember that anything in a textbox is automatically a string.
You cannot do calculations on strings. You can use the Val function as stated above, also, you should check out the cInt, cDbl, cLng functions as well.
These functions convert a string to an integer, double, or long
Ie.
mynewnumber = myoldnumber + cInt(Text1.Text) 'integer
mynewnumber = myoldnumber + cDbl(Text1.Text) 'doubles
mynewnumber = myoldnumber + cLng(Text1.Text) 'long
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|