|
-
Oct 14th, 2004, 11:27 PM
#1
Thread Starter
Lively Member
input decimal point(resolved)
hello all
i have a simple program that allows users to input numbers by key board or buttons clicked my problem is getting a decimal point to display and be put in the variable used for calculation
by clicking the button "." any ideas thanks john
Last edited by jwisneski; Oct 16th, 2004 at 11:32 AM.
-
Oct 14th, 2004, 11:49 PM
#2
To tell you the truth, I have absolutely NO idea what you just said, but I'll hazard a guess here:
VB Code:
If Not TextBox1.Text.IndexOf(".") > 0 Then
TextBox1.Text = TextBox1.Text & "."
End If
-
Oct 15th, 2004, 08:31 AM
#3
Thread Starter
Lively Member
reply
hello mendhak
i have reread my post and it is a bit fuzzy, i have tried your suggestion and it does indeed put a decimal point into the
textbox however the way i have the other buttons coded i lose the decimal place after i input another value, this is a sample
i have n1 declared as public decimal
if n1>=1 then
n1=(n1 * 10) + 2 <--diff value for each button 1,2,3,etc
end if
if n1 = 0 then
n1 = 2 <--- value of button 1,2,3,4 etc
end if
txtnum1.text=n1
this code gives correct input until i use decimal point
how can i recode the numbers(buttons) so the decimal point remains after i put it in the n1 variable thanks john
-
Oct 15th, 2004, 08:45 AM
#4
type the entire number into the textbox first then send it to the variable.
I don't live here any more.
-
Oct 15th, 2004, 12:12 PM
#5
Thread Starter
Lively Member
reply
hello wossname
it works fine the way it is if i type the numbers in using the keyboard i need to use the buttons to enter the numbers
i am thinking of using string.endswith(.) to check for a decimal point. then starting a new variable say n2 for all input after the decimal point and then simply adding the two together
numberbeforedecimal + number afterdecimal=finalnumber
if ther was some simpler way to input the numbers though the use of buttons i wish someone would tell me thanks john
is there a way to check a string for integer vs decimal something like the isnumeric checks for numeric data
Last edited by jwisneski; Oct 15th, 2004 at 10:28 PM.
-
Oct 16th, 2004, 11:31 AM
#6
Thread Starter
Lively Member
final reply
hello all
i found the solution to my problem by simplifing how i input the numbers
n1=txtnum1.text & "."
n1 =txtnum1.text & "1" for all numbers 1,2,3,4,etc
i had a rather compicated method that involved division by ten to move a decimal place
thanks for all your help john
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
|