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. checking for a numeric value in a loop

checking for a numeric value in a loop

Scheduled Pinned Locked Moved Visual Basic
helpquestionannouncement
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

    With Adodc4.Recordset .MoveFirst Do While Not .EOF Dim strPriceCode As String strPriceCode = DataGrid1.Columns("PriceCode") Dim codeSQL As String codeSQL = "Select PriceCode " & _ " From PriceDescription " & _ " Where PriceCode = '" & strPriceCode & "'" Set RS = Conn.Execute(codeSQL) If RS.BOF And RS.EOF Then MsgBox " '" & strPriceCode & "' Price code does not exist - please try another", vbExclamation, "Invalid data" End If DataGrid1.Columns("Price") = txtTest.Text If Not IsNumeric(Me.txtTest.Text) Then MsgBox "Please enter a valid value for Quantity", vbExclamation, "Missing Quantity" Exit Sub End If Dim cPrice As Currency cPrice = DataGrid1.Columns("Price") 'updating the price table Dim updateSQL As String updateSQL = "Update Price set price = " & cPrice & " " & _ " where PriceCode = '" & strPriceCode & "' " & _ " AND ProductCode = '" & strProductCode & "'" Set RS = Conn.Execute(updateSQL) .MoveNext Loop End With to (attempt to!) explain the above code, i am saving 1 column of a datagrid, and looping through it by means of the Recordset that it is bound to at run time. However, i want to ensure that the value entered at each record is a numberic value, so it has to be included in the loop as can be seen above. However, when i try to run it ( and enter a non-numeric value to test it) i get the following error " Multiple step operation generated errors - check each status value"....is there anything i can do to fix this? if you need any additional information, please let me know! Thanks in advance!

    X 1 Reply Last reply
    0
    • M mcm

      With Adodc4.Recordset .MoveFirst Do While Not .EOF Dim strPriceCode As String strPriceCode = DataGrid1.Columns("PriceCode") Dim codeSQL As String codeSQL = "Select PriceCode " & _ " From PriceDescription " & _ " Where PriceCode = '" & strPriceCode & "'" Set RS = Conn.Execute(codeSQL) If RS.BOF And RS.EOF Then MsgBox " '" & strPriceCode & "' Price code does not exist - please try another", vbExclamation, "Invalid data" End If DataGrid1.Columns("Price") = txtTest.Text If Not IsNumeric(Me.txtTest.Text) Then MsgBox "Please enter a valid value for Quantity", vbExclamation, "Missing Quantity" Exit Sub End If Dim cPrice As Currency cPrice = DataGrid1.Columns("Price") 'updating the price table Dim updateSQL As String updateSQL = "Update Price set price = " & cPrice & " " & _ " where PriceCode = '" & strPriceCode & "' " & _ " AND ProductCode = '" & strProductCode & "'" Set RS = Conn.Execute(updateSQL) .MoveNext Loop End With to (attempt to!) explain the above code, i am saving 1 column of a datagrid, and looping through it by means of the Recordset that it is bound to at run time. However, i want to ensure that the value entered at each record is a numberic value, so it has to be included in the loop as can be seen above. However, when i try to run it ( and enter a non-numeric value to test it) i get the following error " Multiple step operation generated errors - check each status value"....is there anything i can do to fix this? if you need any additional information, please let me know! Thanks in advance!

      X Offline
      X Offline
      xBlitzerx
      wrote on last edited by
      #2

      im new to programming... but couldn't you use the IsNumeric() function, if u get true back, just convert it to whichever type u need? CInt, CSng, CDec...etc. Sorry if i don't know what i'm talking about ______________________________________________ "I'm not me when I dream...anymore." -TRUSTcompany

      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