Results 1 to 6 of 6

Thread: input decimal point(resolved)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Location
    suburb of cleveland
    Posts
    72

    Resolved 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.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    To tell you the truth, I have absolutely NO idea what you just said, but I'll hazard a guess here:

    VB Code:
    1. If Not TextBox1.Text.IndexOf(".") > 0 Then
    2.             TextBox1.Text = TextBox1.Text & "."
    3.         End If

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Location
    suburb of cleveland
    Posts
    72

    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

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    type the entire number into the textbox first then send it to the variable.
    I don't live here any more.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Location
    suburb of cleveland
    Posts
    72

    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.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Location
    suburb of cleveland
    Posts
    72

    Resolved 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
  •  



Click Here to Expand Forum to Full Width