Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: VB question...

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I'm not sure if this is possible but I'll ask anyhoo.

    I have this code:
    ---
    Private Sub CalcButton_Click()

    If CostBox.Value = "?" Then
    MsgBox ("Invalid Cost")
    CostBox.Value = ""
    Else

    If CostBox.Value = "?" Then
    a = CostBox.Value
    b = QuantityBox.Value
    answer = a * b
    SubCostBox.Text = answer
    End If
    End If
    End Sub
    ---
    The question marks are the problem. I need CostBox.Value to be any number but NOT a letter. Are there any wildcards I could use, one for letters and one for numbers?

    Any help or put-downs at my gross incompetence would be much appreciated!

    stiffrimpet


  2. #2
    Board Regular
    Join Date
    Mar 2002
    Posts
    363
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try using the val function

    if val(CostBox.Value) = 0 then
    msgbox "you must enter numbers only
    CostBox.Value = 0
    endif
    It's never too late to learn something new.

    Ricky

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi
    Another function as well...

    If Not IsNumeric(CostBox.Text) Then
    Msgbox "You must enter numbers only."
    CostBox.Text = ""
    CostBox.SetFocus
    End If

    Tom

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •