Results 1 to 2 of 2

Thread: text box help

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    10

    Im using the following function

    Public Function CheckText(MyText As String) As Boolean

    'function returns True if text is OK else returns False

    If MyText = "" Then
    CheckText = False
    Exit Function
    End If


    If Not IsNumeric(MyText) Then
    CheckText = False
    Exit Function
    End If

    'If we get to here, MyText is a number
    ' So set function to true

    heckText = True

    End Function

    and then calling it when I enter data in a text box to stop errors I was getting if the box was empty or didn't have a number in it.

    The code is


    Private Sub txtsupplyfo2_Change()


    If CheckText(txtsupplyfo2.Text) = True Then

    'do the calculations for related data

    txtmaxpo2.Text = txtsupplyfo2.Text * txtbar.Text

    txtfio2.Text = ((txttotaldump.Text * txtsupplyfo2.Text) - txtconsumption.Text) /(txttotaldump.Text - txtconsumption.Text)
    Else
    txtsupplyfo2.Text = ""
    End If

    End Sub

    The problem is....in the calculation I can have txtsupplyfo2.Text with a value greater than 1 but with this code I am only able to enter whole numbers.
    How can I change it to let decimals be entered. Or should I just have the user enter a whole number (%) and then do a calculation to make the number a fraction before I use it to calculate the other visible data?

    please help.

    Thanks,
    Scott

    PS Does anyone here know where I can get some live one on one lessons or training for vb in Sydney, Australia?
    __________________
    Trying to teach myself visual basic

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    If you can e-mail me the form with all of this already on it, I might be able to debug it for you. I tried using the posted code but I think there may be some miscommunication.

    [email protected]
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

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