By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

ValidateTextBox is not defined

P: 3
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2. Imports System.Data.SqlClient
  3.  
  4. Public Class Form2
  5.     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"
  6.     Public conn As New OleDbConnection
  7.  
  8.     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  9.         'TODO: This line of code loads data into the 'DatabaseDataSet.Status' table. You can move, or remove it, as needed.
  10.         Me.StatusTableAdapter.Fill(Me.DatabaseDataSet.Status)
  11.         'TODO: This line of code loads data into the 'DatabaseDataSet.View_Instructors' table. You can move, or remove it, as needed.
  12.         Me.View_InstructorsTableAdapter.Fill(Me.DatabaseDataSet.View_Instructors)
  13.         'TODO: This line of code loads data into the 'DatabaseDataSet.View_Courses' table. You can move, or remove it, as needed.
  14.         Me.View_CoursesTableAdapter.Fill(Me.DatabaseDataSet.View_Courses)
  15.         'TODO: This line of code loads data into the 'DatabaseDataSet.Status_Year_Level_and_Program' table. You can move, or remove it, as needed.
  16.         Me.Status_Year_Level_and_ProgramTableAdapter.Fill(Me.DatabaseDataSet.Status_Year_Level_and_Program)
  17.         'TODO: This line of code loads data into the 'DatabaseDataSet.Student_Registration' table. You can move, or remove it, as needed.
  18.         Me.Student_RegistrationTableAdapter.Fill(Me.DatabaseDataSet.Student_Registration)
  19.  
  20.         conn.ConnectionString = connstring
  21.  
  22.         'to test if the connection to the database is open
  23.         If conn.State = ConnectionState.Closed Then
  24.             conn.Open()
  25.             MsgBox("Database connection is now open")
  26.         Else
  27.             MsgBox("Database Connection has been Closed")
  28.         End If
  29.  
  30.     End Sub
  31.  
  32.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  33.  
  34.         Dim clsValidate As New ValidateTextBox
  35.  
  36.         'validating empty txtID
  37.         If clsValidate.IsTextBoxEmpty(txtID) = True Then
  38.             MessageBox.Show("Please enter ID")
  39.             Exit Sub
  40.         End If
  41.  
  42.         'validating a numeric input for ID
  43.         If clsValidate.IsTextBoxNumeric(txtID) = False Then
  44.             MessageBox.Show("Please enter a valid ID")
  45.             Exit Sub
  46.         End If
  47.  
  48.         'validating the an empty textLName
  49.         If clsValidate.IsTextBoxEmpty(txtLName) Then
  50.             MessageBox.Show("Please enter First Name")
  51.             Exit Sub
  52.         End If
  53.  
  54.         'validating a character input for LastName
  55.         If clsValidate.IsTextBoxNumeric(txtLName) = True Then
  56.             MessageBox.Show("Please enter a valid First Name")
  57.             Exit Sub
  58.         End If
  59.  
  60.         'validating the an empty textFName
  61.         If clsValidate.IsTextBoxEmpty(txtFName) Then
  62.             MessageBox.Show("Please enter First Name")
  63.             Exit Sub
  64.         End If
  65.  
  66.         'validating a character input for FirstName
  67.         If clsValidate.IsTextBoxNumeric(txtFName) = True Then
  68.             MessageBox.Show("Please enter a valid First Name")
  69.             Exit Sub
  70.         End If
  71.  
  72.         'validating the an empty textMName
  73.         If clsValidate.IsTextBoxEmpty(txtMName) Then
  74.             MessageBox.Show("Please enter Middle Name")
  75.             Exit Sub
  76.         End If
  77.  
  78.         'validating a character input for MiddleName
  79.         If clsValidate.IsTextBoxNumeric(txtMName) = True Then
  80.             MessageBox.Show("Please enter a valid Middle Name")
  81.             Exit Sub
  82.         End If
  83.  
  84.         'validating empty txtContact1
  85.         If clsValidate.IsTextBoxEmpty(txtContact1) = True Then
  86.             MessageBox.Show("Please enter Contact Number")
  87.             Exit Sub
  88.         End If
  89.  
  90.         'validating a numeric input for txtContact1
  91.         If clsValidate.IsTextBoxNumeric(txtContact1) = False Then
  92.             MessageBox.Show("Please enter a valid Contact Number")
  93.             Exit Sub
  94.         End If
  95.  
  96.         'validating the an empty txtAddress
  97.         If clsValidate.IsTextBoxEmpty(txtAddress) Then
  98.             MessageBox.Show("Please enter Address")
  99.             Exit Sub
  100.         End If
  101.  
  102.         'validating a character input for txtAddress
  103.         If clsValidate.IsTextBoxNumeric(txtAddress) = True Then
  104.             MessageBox.Show("Please enter a valid Address")
  105.             Exit Sub
  106.         End If
  107.  
  108.         'validating the an empty txtGuardian
  109.         If clsValidate.IsTextBoxEmpty(txtGuardian) Then
  110.             MessageBox.Show("Please enter Guardian Name")
  111.             Exit Sub
  112.         End If
  113.  
  114.         'validating a character input for Guardian
  115.         If clsValidate.IsTextBoxNumeric(txtGuardian) = True Then
  116.             MessageBox.Show("Please enter a valid Guardian Name")
  117.             Exit Sub
  118.         End If
  119.  
  120.         'validating empty txtContact2
  121.         If clsValidate.IsTextBoxEmpty(txtContact2) = True Then
  122.             MessageBox.Show("Please enter Contact Number")
  123.             Exit Sub
  124.         End If
  125.  
  126.         'validating a numeric input for txtContact2
  127.         If clsValidate.IsTextBoxNumeric(txtContact2) = False Then
  128.             MessageBox.Show("Please enter a valid Contact Number")
  129.             Exit Sub
  130.         End If
  131.  
  132.         'inserting the new record to database
  133.         Try
  134.             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 & "')"
  135.             Dim SqlCommand As New OleDbCommand
  136.  
  137.             With SqlCommand
  138.                 .CommandText = SqlQuery
  139.                 .Connection = conn
  140.                 .ExecuteNonQuery()
  141.             End With
  142.             MsgBox("Record Succesfully Added")
  143.  
  144.             'refreshing the textbox for new record
  145.             txtID.Text = ""
  146.             txtLName.Text = ""
  147.             txtFName.Text = ""
  148.             txtMName.Text = ""
  149.             txtContact1.Text = ""
  150.             txtAddress.Text = ""
  151.             txtGuardian.Text = ""
  152.             txtContact2.Text = ""
  153.  
  154.         Catch ex As Exception
  155.             MsgBox(ex.Message)
  156.         End Try
  157.  
  158.     End Sub
  159. End Class
Oct 21 '13 #1
Share this Question
Share on Google+
4 Replies


P: 3
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!
Oct 21 '13 #2

pod
100+
P: 298
pod
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 "ValidateTextBox" 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 "ValidateTextBox" with its two functions; IsTextBoxEmpty, IsTextBoxNumeric ... or write your own class (the latter would be a better learning experience ;)


Good luck

P:oD
Oct 21 '13 #3

P: 3
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 "ValidateTextBox is not defined", Thank you for the reply, I will try to declare class name ValidateTextBox, I hope it will work. :)
Oct 21 '13 #4

Rabbit
Expert Mod 10K+
P: 12,383
ValidateTextBox looks like some sort of third party control. But I don't see that you bring in the third party code anywhere.
Oct 22 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Browse more Visual Basic .NET Questions on Bytes