Results 1 to 3 of 3

Thread: txtbox hell

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    10
    ok im using

    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

    CheckText = True

    End Function

    then calling it and doing some calculations with

    Private Sub txtsupplyfo2_Change()


    If CheckText(txtsupplyfo2.Text) = True Then

    'do the calculations for related datatxtmaxpo2.Text = txtsupply.Text * txtbar.Text
    txtmaxpo2.Text = txt.supplyfo2.Text * txtbar.Text
    txtfio2.Text = ((txttotaldump.Text * txtsupplyfo2.Text) - txtconsumption.Text) / (txttotaldump.Text - txtconsumption.Text)
    Else
    txtmaxpo2.Text = ""
    txtfio2.Text = ""
    End If

    End Sub

    all this works fine until I do the one above where there are 2 calculations. Also txtdepth_Change (not seen above) is used calculates txtbar.Text and txtmaxpo2.Text and txtbar_Change calculates txtdepth.Text and txtmaxpo2.text

    Is the problem that I am not supposed to the same calculation from two difeerent txt box changes? Or is it that I have numerous txt boxes cross calculating the same data as other checkboxes???

    Help me please.

    Scott
    Trying to teach myself visual basic

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    I'm not sure to solve your problem but dont calculate in the text box,
    do you operation by LONG or INTEGER variable...
    cause if you do that:
    text1=text1+1
    visual basic will have somme problem to know if he nedd to do
    11
    or
    2

    normally, You will recieve 11 cause it's STRING ..

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    to get around the string deal as textboxes are string by default use the Val function

    Val(Text1) + Val(Text2)...etc or
    "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
  •  



Click Here to Expand Forum to Full Width