Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. type mismatch

type mismatch

Scheduled Pinned Locked Moved Visual Basic
testingbeta-testinghelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mcm
    wrote on last edited by
    #1

    i am trying to perform form validation on my Order Generation form. In testing for a valid quantity, i use the following if statements ElseIf (Me.txtQuantity.Text = "") Then MsgBox "Please enter a value for Quantity" ElseIf Val(iQuantity) = 0 Then MsgBox "Please enter a value for Product code" ElseIf IsNumeric(iQuantity) = False MsgBox "Please enter a value for Product code" However, is doesnt seem to recognize these statements as when i dont enter a value for quantity, a message box should pop up but instead i hit a runtime error saying "type mismatch"...why is this - is there anything i can do about it? Thank you in advance!

    S 1 Reply Last reply
    0
    • M mcm

      i am trying to perform form validation on my Order Generation form. In testing for a valid quantity, i use the following if statements ElseIf (Me.txtQuantity.Text = "") Then MsgBox "Please enter a value for Quantity" ElseIf Val(iQuantity) = 0 Then MsgBox "Please enter a value for Product code" ElseIf IsNumeric(iQuantity) = False MsgBox "Please enter a value for Product code" However, is doesnt seem to recognize these statements as when i dont enter a value for quantity, a message box should pop up but instead i hit a runtime error saying "type mismatch"...why is this - is there anything i can do about it? Thank you in advance!

      S Offline
      S Offline
      SimonS
      wrote on last edited by
      #2

      I'd recommend the following: - create a local variable based on a Trim() of the txtQuantity.Text - check length first - next, check for a false on IsNumeric() - only then look for certain integer values HTH limit further bugs btw, which line are you getting the type mismatch from? Cheers, Simon "The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
      my svg article

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups