Results 1 to 2 of 2

Thread: help with text box data

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    10
    Hi,
    Im using the following code to stop errors I was getting when textbox data was blank. I call it from the text box part of the code before the calculation im doing.

    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

    this works great with whole numbers but one of the boxes I'm using requires a decimal place and this still lets it cause an error. Is there anything I can use similar that will also check for decimal numbers.

    Thanks, Scott

    btw This forum is great, I got a super quick answer last time. I'm learning more here than in nearly all the tutorials and books ive read. Much more practical info. Thanks all.
    Trying to teach myself visual basic

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Location
    A caravan park in the Midlands (UK)
    Posts
    101

    Question

    Are you saying that that your CheckText function returns TRUE and then you get an error because the calculation still rejects a dp?

    If so when true is returned convert your string to a double and use the double in the calc.

    dim ld as double


    if checktext(myText) then
    ld = cdl(mytext)
    else
    ld =0
    end if

    Anakim

    It's a small world but I wouldn't like to paint it.

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