mardi 5 mai 2015

Convert Data Set Object .text to Int32 Visual Basic

Hullo,

I am using a database with my Visual Basic application, and arranged code for a simple add and display procedure (see below). The fields are shown as text boxes with the DataType properties set as Int32, and DateTime as UnspecifiedLocal by default. I am repeatedly getting an error that input string is not in the correct format and it insists I am trying to convert DateTime. I have tried changing the DataType to String and removing the convert.toint32 but it still gives me the error that the input string is not in the correct format. I would greatly appreciate your help on how to resolve this error message and fix my simple little procedure! Thank you!!

Private Sub StrTol()
    Dim intBase As Integer = Convert.ToInt32(Base_Score1TextBox.Text)
    Dim intRace As Integer = Convert.ToInt32(Base_Race_Mod1TextBox.Text)
    Dim intEnh As Integer = Convert.ToInt32(Enh_Bonus1TextBox.Text)
    Dim intMisc As Integer = Convert.ToInt32(Mis1TextBox.Text)
    Dim intSum As Integer

    If intBase > 0 Then
    ElseIf intRace > 0 Then
    ElseIf intEnh > 0 Then
    ElseIf intMisc > 0 Then
        intSum = intBase + intRace + intEnh + intMisc
        txtStr.Text = intSum
    Else
        MsgBox("Input Error", MsgBoxStyle.OkOnly, "Error")

    End If

Aucun commentaire:

Enregistrer un commentaire