ValidateTextBox is not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MeGotLotsoQs
    New Member
    • Oct 2013
    • 3

    ValidateTextBox is not defined

    Code:
    Imports System.Data.OleDb
    Imports System.Data.SqlClient
    
    Public Class Form2
        Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\REORBETA\Desktop\COPRO VB NET PROGRAM FINALS\VB NET Database\Database\Database\Database.accdb"
        Public conn As New OleDbConnection
    
        Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'DatabaseDataSet.Status' table. You can move, or remove it, as needed.
            Me.StatusTableAdapter.Fill(Me.DatabaseDataSet.Status)
            'TODO: This line of code loads data into the 'DatabaseDataSet.View_Instructors' table. You can move, or remove it, as needed.
            Me.View_InstructorsTableAdapter.Fill(Me.DatabaseDataSet.View_Instructors)
            'TODO: This line of code loads data into the 'DatabaseDataSet.View_Courses' table. You can move, or remove it, as needed.
            Me.View_CoursesTableAdapter.Fill(Me.DatabaseDataSet.View_Courses)
            'TODO: This line of code loads data into the 'DatabaseDataSet.Status_Year_Level_and_Program' table. You can move, or remove it, as needed.
            Me.Status_Year_Level_and_ProgramTableAdapter.Fill(Me.DatabaseDataSet.Status_Year_Level_and_Program)
            'TODO: This line of code loads data into the 'DatabaseDataSet.Student_Registration' table. You can move, or remove it, as needed.
            Me.Student_RegistrationTableAdapter.Fill(Me.DatabaseDataSet.Student_Registration)
    
            conn.ConnectionString = connstring
    
            'to test if the connection to the database is open
            If conn.State = ConnectionState.Closed Then
                conn.Open()
                MsgBox("Database connection is now open")
            Else
                MsgBox("Database Connection has been Closed")
            End If
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim clsValidate As New ValidateTextBox
    
            'validating empty txtID
            If clsValidate.IsTextBoxEmpty(txtID) = True Then
                MessageBox.Show("Please enter ID")
                Exit Sub
            End If
    
            'validating a numeric input for ID
            If clsValidate.IsTextBoxNumeric(txtID) = False Then
                MessageBox.Show("Please enter a valid ID")
                Exit Sub
            End If
    
            'validating the an empty textLName
            If clsValidate.IsTextBoxEmpty(txtLName) Then
                MessageBox.Show("Please enter First Name")
                Exit Sub
            End If
    
            'validating a character input for LastName
            If clsValidate.IsTextBoxNumeric(txtLName) = True Then
                MessageBox.Show("Please enter a valid First Name")
                Exit Sub
            End If
    
            'validating the an empty textFName
            If clsValidate.IsTextBoxEmpty(txtFName) Then
                MessageBox.Show("Please enter First Name")
                Exit Sub
            End If
    
            'validating a character input for FirstName
            If clsValidate.IsTextBoxNumeric(txtFName) = True Then
                MessageBox.Show("Please enter a valid First Name")
                Exit Sub
            End If
    
            'validating the an empty textMName
            If clsValidate.IsTextBoxEmpty(txtMName) Then
                MessageBox.Show("Please enter Middle Name")
                Exit Sub
            End If
    
            'validating a character input for MiddleName
            If clsValidate.IsTextBoxNumeric(txtMName) = True Then
                MessageBox.Show("Please enter a valid Middle Name")
                Exit Sub
            End If
    
            'validating empty txtContact1
            If clsValidate.IsTextBoxEmpty(txtContact1) = True Then
                MessageBox.Show("Please enter Contact Number")
                Exit Sub
            End If
    
            'validating a numeric input for txtContact1
            If clsValidate.IsTextBoxNumeric(txtContact1) = False Then
                MessageBox.Show("Please enter a valid Contact Number")
                Exit Sub
            End If
    
            'validating the an empty txtAddress
            If clsValidate.IsTextBoxEmpty(txtAddress) Then
                MessageBox.Show("Please enter Address")
                Exit Sub
            End If
    
            'validating a character input for txtAddress
            If clsValidate.IsTextBoxNumeric(txtAddress) = True Then
                MessageBox.Show("Please enter a valid Address")
                Exit Sub
            End If
    
            'validating the an empty txtGuardian
            If clsValidate.IsTextBoxEmpty(txtGuardian) Then
                MessageBox.Show("Please enter Guardian Name")
                Exit Sub
            End If
    
            'validating a character input for Guardian
            If clsValidate.IsTextBoxNumeric(txtGuardian) = True Then
                MessageBox.Show("Please enter a valid Guardian Name")
                Exit Sub
            End If
    
            'validating empty txtContact2
            If clsValidate.IsTextBoxEmpty(txtContact2) = True Then
                MessageBox.Show("Please enter Contact Number")
                Exit Sub
            End If
    
            'validating a numeric input for txtContact2
            If clsValidate.IsTextBoxNumeric(txtContact2) = False Then
                MessageBox.Show("Please enter a valid Contact Number")
                Exit Sub
            End If
    
            'inserting the new record to database
            Try
                Dim SqlQuery As String = "INSERT INTO Friends (ID, Last Name, First Name, Middle Name, Contact Number, Address, Guardian, Contact Number) VALUES ('" & txtID.Text & "','" & txtLName.Text & "','" & txtFName.Text & "','" & txtMName.Text & "','" & txtContact1.Text & "','" & txtAddress.Text & "','" & txtGuardian.Text & "','" & txtContact2.Text & "')"
                Dim SqlCommand As New OleDbCommand
    
                With SqlCommand
                    .CommandText = SqlQuery
                    .Connection = conn
                    .ExecuteNonQuery()
                End With
                MsgBox("Record Succesfully Added")
    
                'refreshing the textbox for new record
                txtID.Text = ""
                txtLName.Text = ""
                txtFName.Text = ""
                txtMName.Text = ""
                txtContact1.Text = ""
                txtAddress.Text = ""
                txtGuardian.Text = ""
                txtContact2.Text = ""
    
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
        End Sub
    End Class
    Last edited by Rabbit; Oct 22 '13, 12:30 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • MeGotLotsoQs
    New Member
    • Oct 2013
    • 3

    #2
    We were told to make a project that uses database, We are using VB.NET with either SQL or using MS Access, I used Access on mine since it was troublesome download since its time consuming and I have Access ready in my PC.

    Having trouble with this, please help oh great programmers hehe!

    Comment

    • pod
      Contributor
      • Sep 2007
      • 298

      #3
      I'll go out o a limb here and say that this is the first run at it, am I right?

      If so then I suggest to use small steps:
      first step,connect to the database, and display a message depending if successful or not.
      Test it!
      When this succeeds, add another step; get a record from a table and show the result in a message.
      Test it!
      ... and so forth.

      If this is not your first run and you were progressing well until you added the "ValidateTextBo x" call then the message is telling you what is wrong, ... ValidateTextBox is not defined ... in your code a least.

      If you took this portion of the code from some other project, you only got part of it; go back and look for the class named "ValidateTextBo x" with its two functions; IsTextBoxEmpty, IsTextBoxNumeri c ... or write your own class (the latter would be a better learning experience ;)


      Good luck

      P:oD

      Comment

      • MeGotLotsoQs
        New Member
        • Oct 2013
        • 3

        #4
        I did test the connection to the database and it was successful. Yes, I did take this portion of validation from our three previous exercises but there were no class ValidateTextBox declared but it executes well and there were no error. Im confused with what's happening to my project, hahaha, in all four forms, the only errors I got was the same error which is "ValidateTextBo x is not defined", Thank you for the reply, I will try to declare class name ValidateTextBox , I hope it will work. :)

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          ValidateTextBox looks like some sort of third party control. But I don't see that you bring in the third party code anywhere.

          Comment

          Working...