|
-
Oct 12th, 2012, 09:17 AM
#1
Thread Starter
Fanatic Member
How to divide numbers
Hi guys does anybody know how i can make it divide the numbers put in text1 and text 2?
for example
text 1 = 100
text 2 = 4
when command1 is pressed it then divides text1 by text2
any ideas?
thanks
Jamie
-
Oct 12th, 2012, 09:28 AM
#2
Re: How to divide numbers
Code:
Dim dblResult As Double
dblResult = Val(Text1.Text) / Val(Text2.Text)
-
Oct 12th, 2012, 09:36 AM
#3
Thread Starter
Fanatic Member
Re: How to divide numbers
fantastic thank you, by anychance do you know how i can make it choose the number to divide it by automatically?
Basically i have 2 dtpicker boxes and a user selects 2 diffrent dates, is it possible to make it divide it by the number of different days?
For example dtpicker1 = 08/04/2012 and dtpicker2 = 10/04/2012
it will know to divide it by 2 as thats the day difference?
Thanks
Jamie
-
Oct 12th, 2012, 10:03 AM
#4
Re: How to divide numbers
Use the DateDiff function to find out the amount of days
-
Oct 13th, 2012, 02:24 AM
#5
Re: How to divide numbers
Try this
Code:
Dim dblResult As Double
dblResult = Val(Text1.Text) / DateDiff("d", "08/04/2012", "10/04/2012") ' Replace dates with dtpicker1 & dtpicker2
-
Oct 15th, 2012, 04:46 AM
#6
Thread Starter
Fanatic Member
Re: How to divide numbers
Hi mate,
For some reason the code you provided is not returning any values, so it is just displaying empty results and not actually showing any numbers.
Any ideas?
-
Oct 15th, 2012, 05:07 AM
#7
Re: How to divide numbers
The returning value is stored in the variable dblResult, so you have to show it in a control like Text box or Label, e.g.
Text2.Text = CStr(dblResult)
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
|