IndexOutOfRangeException was Unhandled. Cannot find table 0 - vb.net

can anyone please help on how to fix this error? im getting an error "Error:Syntax error(missing operator)in query expression '''ans'." this is my code:
Imports System.Data
Imports System.Data.OleDb
Public Class frmExam : Inherits System.Windows.Forms.Form
Dim ds As New DataSet()
Dim qno() As Integer
Dim pos As Integer
Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFinish.Click
ProcessAnswer()
Dim i, marks As Integer
Dim dr As DataRow
marks = 0
For i = 0 To NOQ - 1
dr = ds.Tables(0).Rows(qno(i))
If Not IsDBNull(dr.Item("ans")) AndAlso dr.Item("CorrectAns") = dr.Item("ans") Then
marks += 1
End If
Next
Try
con.Open()
Dim cmd As New OleDbCommand("insert into stud values(stud.nextval,'" & SubjectCode & "','" & Username & "','" & marks & ")", con)
MsgBox(cmd.CommandText)
cmd.ExecuteNonQuery()
Dim msg As String
msg = "UserName : " & Username & ControlChars.CrLf & _
"Subject : " & SubjectCode & ControlChars.CrLf & _
"Total Questions : " & NOQ & ControlChars.CrLf & _
"Marks : " & marks
MsgBox(msg, "Result")
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State <> ConnectionState.Closed Then
con.Close()
End If
End Try
Me.Dispose()
End Sub
Private Sub frmExam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReDim qno(NOQ)
Try
Dim da As New OleDbDataAdapter("select Question, Ans1, Ans2, Ans3, Ans4, CorrectAns, QType, '' ans from question where SubjectCode = " & SubjectCode, con)
da.Fill(ds, "question")
Catch ex As Exception
MsgBox("Error:" & ex.Message)
Me.Dispose()
End Try
Randomize()
Dim totrows As Integer
totrows = ds.Tables(0).Rows.Count
Dim i, r, j As Integer
Dim present As Boolean
i = 0
Do While i < 5
r = CInt((totrows - 1) * Rnd())
present = False
For j = 0 To i
If r = qno(j) Then
present = True
Exit For
End If
Next
If Not present Then
qno(i) = r
i = i + 1
End If
Loop
pos = 0
DisplayQuestion()
End Sub
Sub DisplayQuestion()
Dim row As DataRow
lblQno.Text = Str(pos + 1) & "/" & NOQ
lblSubcode.Text = "Subject : " & SubjectCode
row = ds.Tables(0).Rows(qno(pos))
txtQuestion.Text = row.Item(0)
txtAns1.Text = row.Item(1)
txtAns2.Text = row.Item(2)
txtAns3.Text = row.Item(3)
txtAns4.Text = row.Item(4)
lblQNo2.Text = Str(pos + 1) & "/" & NOQ
lblSubCode2.Text = "Subject:" & SubjectCode
row = ds.Tables(0).Rows(qno(pos))
txtQuestion2.Text = row.Item(0)
txtAnsTrue.Text = row.Item(1)
txtAnsFalse.Text = row.Item(2)
lblQNo3.Text = Str(pos + 1) & "/" & NOQ
lblSubcode.Text = "Subject : " & SubjectCode
row = ds.Tables(0).Rows(qno(pos))
txtQuestion3.Text = row.Item(1)
txtAns.Text = row.Item(2)
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
ProcessAnswer()
If pos < NOQ - 1 Then
pos = pos + 1
DisplayQuestion()
Else
Beep()
End If
End Sub
Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
ProcessAnswer()
If pos > 0 Then
pos = pos - 1
DisplayQuestion()
End If
End Sub
Public Sub ProcessAnswer()
Dim row As DataRow
Dim ans As String = ""
row = ds.Tables(0).Rows(qno(pos))
If rdbtnAns1.Checked Then
ans = "1"
End If
If rdbtnAns2.Checked Then
ans = "2"
End If
If rdbtnAns3.Checked Then
ans = "3"
End If
If rdbtnAns4.Checked Then
ans = "4"
End If
If rdbtnTrue.Checked Then
ans = "1"
End If
If rdbtnFalse.Checked Then
ans = "2"
End If
If txtAns.Text = "" Then
ans = "txtAns"
End If
ds.Tables(0).Rows(qno(pos)).Item("Ans1") = ans
End Sub
Private Sub btnPrev2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev2.Click
ProcessAnswer()
If pos > 0 Then
pos = pos - 1
DisplayQuestion()
End If
End Sub
Private Sub btnNext2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext2.Click
ProcessAnswer()
If pos < NOQ - 1 Then
pos = pos + 1
DisplayQuestion()
Else
Beep()
End If
End Sub
Private Sub btnPrev3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev3.Click
ProcessAnswer()
If pos > 0 Then
pos = pos - 1
DisplayQuestion()
End If
End Sub
Private Sub btnNext3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext3.Click
ProcessAnswer()
If pos < NOQ - 1 Then
pos = pos + 1
DisplayQuestion()
Else
Beep()
End If
End Sub
End Class
this is the highlighted texxt:totrows = ds.Tables(0).Rows.Count

When you want to use an alias for a field expression, Access requires you to use the AS keyword.
This would fail ...
select Question, Ans1, Ans2, Ans3, Ans4, CorrectAns, QType, '' ans from question
This could work ...
select Question, Ans1, Ans2, Ans3, Ans4, CorrectAns, QType, '' AS ans from question
However, I would be uneasy with a field whose name matched the table name. If you can't rename that field, alias the table, and qualify the fields with the table alias.
select q.Question, q.Ans1, q.Ans2, q.Ans3, q.Ans4, q.CorrectAns, q.QType, '' AS ans from question AS q

Related

Debugging in vb.net?

I'm new to coding, I've been working on my project of online billing system using Visual Basic.
The complete coding has been done, but while running the code, the totalitems and totalamt is not being calculated. Can you please debug or guide me how can I resolve this issue...
It shows errors like
1.conversion of type dbnull to string is not valid
2.string or binary data would be truncated.
Public Class billing
Dim disAmount As Double
Dim getProducID As Integer
Dim getStocks As Integer
Dim validatestock As Integer
Dim getUnitPrice As Double
Dim loadqty As Double
Dim discount As Boolean
Private Sub billing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
getTransactionID()
GenerateInvoiceNo()
fillComboproduct()
End Sub
Private Sub getTransactionID()
Try
Dim trans As New Random
Dim numbers As Integer = trans.Next(1, 1000000)
Dim digitss As String = numbers.ToString("000000")
txttrans.Text = digitss
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub GenerateInvoiceNo()
lblInvoice.Text = "INV-" & GetUniqueKey(8)
End Sub
Public Shared Function GetUniqueKey(ByVal maxSize As Integer) As String
Dim chars As Char() = New Char(61) {}
chars = "123456789".ToCharArray()
Dim data As Byte() = New Byte(0) {}
Dim crypto As New RNGCryptoServiceProvider()
crypto.GetNonZeroBytes(data)
data = New Byte(maxSize - 1) {}
crypto.GetNonZeroBytes(data)
Dim result As New StringBuilder(maxSize)
For Each b As Byte In data
result.Append(chars(b Mod (chars.Length)))
Next
Return result.ToString()
End Function
Private Sub fillComboproduct()
Dim query As String = "Select productname From product order by productname"
Dim dtproduct As DataTable = getDataTable(query)
txtproductame.DataSource = dtproduct
txtproductame.DisplayMember = "productname"
' txtproductame.ValueMember = "productID"
If txtproductame.Items.Count > 0 Then
txtproductame.SelectedIndex = 0
End If
End Sub
Private Sub clear()
txtproductID.Text = ""
txtprice.Text = ""
txtQuantity.Text = ""
txtBalance.Text = ""
txttotal.Text = ""
txtAmtPaid.Text = ""
lblSubTotal.Text = "0"
txtproductame.Text = ""
lblTotalAmount.Text = "0.00"
lblSubTotal.Text = "0.00"
lblTotalItems.Text = "0"
txtprice.Text = ""
txtQuantity.Text = "1"
txttotal.Text = "0.00"
End Sub
Private Sub addbills()
Try
Sql = "INSERT INTO bills VALUES( '" & txtproductID.Text & "', '" & txtproductame.Text & "','" & txtQuantity.Text & "', '" & txtprice.Text & "','" & txttotal.Text & "', '" & lblInvoice.Text & "', '" & Date.Today & "')"
ConnDB()
cmd = New SqlCommand(sqL, conn)
Dim i As Integer
i = cmd.ExecuteNonQuery
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub
Private Sub loadbills()
Try
Sql = "SELECT productID,productname,qty,unitprice FROM bills WHERE invoiceno = '" & Trim(lblInvoice.Text) & "' "
ConnDB()
cmd = New SqlCommand(sqL, conn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dgw.Rows.Clear()
Do While dr.Read = True
dgw.Rows.Add(dr(0), dr(1), dr(2), dr(3))
Loop
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub totalamt()
Try
Sql = "SELECT sum(totalamt) FROM bills where invoiceno = '" & Trim(lblInvoice.Text) & "' "
ConnDB()
cmd = New SqlCommand(sqL, conn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Do While dr.Read = True
lblTotalAmount.Text = dr(0)
Loop
Catch ex As Exception
End Try
End Sub
Private Sub gettotalitems()
Try
Sql = "SELECT sum(qty) FROM bills where invoiceno = '" & Trim(lblInvoice.Text) & "' "
ConnDB()
cmd = New SqlCommand(sqL, conn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Do While dr.Read = True
lblTotalItems.Text = dr(0)
Loop
Catch ex As Exception
End Try
End Sub
Private Sub saveitems()
Try
Sql = "INSERT INTO transactionDetails VALUES('" & txttrans.Text & "','" & lblInvoice.Text & "', '" & lblTotalItems.Text & "', '" & lblTotalAmount.Text & "', '" & txtAmtPaid.Text & "','" & txtBalance.Text & "', '" & cmdpayment.Text & "', '" & Date.Today & "')"
ConnDB()
cmd = New SqlCommand(sqL, conn)
Dim i As Integer
i = cmd.ExecuteNonQuery
If i > 0 Then
MsgBox("Billing Details Successfully saved", MsgBoxStyle.Information, "Saves Billing Details")
Else
MsgBox("Failed in Saves Billing Details", MsgBoxStyle.Information, "Saves Billing Details")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub
Private Sub txtproductame_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtproductame.SelectedIndexChanged
Try
ConnDB()
Dim da As New SqlDataAdapter(("select * from product where productname ='" & Trim(txtproductame.Text) & "'"), conn)
Dim dt As New DataTable
da.Fill(dt)
If dt.Rows.Count > 0 Then
Me.txtprice.Text = dt.Rows(0).Item("unitprice") & ""
Me.txtproductID.Text = dt.Rows(0).Item("productID") & ""
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub txtQuantity_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtQuantity.TextChanged
txttotal.Text = Val(txtQuantity.Text) * Val(txtprice.Text)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
getTransactionID()
GenerateInvoiceNo()
End Sub
Private Sub BindToText()
Try
With dgw
lblSubTotal.Text = Val(.SelectedRows(0).Cells("qty").Value) * Val(.SelectedRows(0).Cells("price").Value)
.SelectedRows(0).Cells("amt").Value = lblSubTotal.Text
End With
Catch ex As Exception
End Try
End Sub
Private Sub dgw_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgw.CellClick
BindToText()
End Sub
Private Sub dgw_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgw.SelectionChanged
BindToText()
End Sub
Private Sub txtAmtPaid_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtAmtPaid.KeyPress
Dim ch As Char = e.KeyChar
If Char.IsLetter(ch) Then 'Ristricting To Input Only Digits(any number)
e.Handled = True
End If
End Sub
Private Sub txtQuantity_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtQuantity.KeyPress
Dim ch As Char = e.KeyChar
If Char.IsLetter(ch) Then 'Ristricting To Input Only Digits(any number)
e.Handled = True
End If
End Sub
Private Sub btnload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnload.Click
Try
txttotal.Text = Val(txtprice.Text) * Val(txtQuantity.Text)
If txtproductame.Text = "" Or txtQuantity.Text = "" Then
MsgBox("Please enter a product Or Quantity before you click load button")
Else
addbills()
loadbills()
totalamt()
gettotalitems()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
txttotal.Text = ""
txtQuantity.Text = ""
End Sub
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
If dgw.Rows.Count = 0 Then
MsgBox("Please load drugs in the cart before saving", MsgBoxStyle.Exclamation, "Validation")
Exit Sub
End If
If txtAmtPaid.Text = "" Then
MsgBox("Please fill-in Amount Paid by Customer", MsgBoxStyle.Information, "Validation")
txtAmtPaid.Focus()
Exit Sub
ElseIf cmdpayment.Text = "" Then
MsgBox("Please choose Payment status field", MsgBoxStyle.Information, "Validation")
cmdpayment.Focus()
Exit Sub
End If
saveitems()
'DecreaseStocksOnhand()
'UpdateToDecreaseStocksOnHand()
btnreceipt.Show()
getTransactionID()
' GenerateInvoiceNo()
dgw.Rows.Clear()
' btnreceipt.Show()
End Sub
Private Sub Deleteitem()
Try
Sql = "DELETE * FROM bills WHERE productID = '" & dgw.SelectedRows(0).Cells("productID").Value & "'"
ConnDB()
cmd = New SqlCommand(sqL, conn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Do While dr.Read = True
dgw.Rows.Add(dr(0), dr(1), dr(2), dr(3))
Loop
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub
Private Sub btnremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnremove.Click
If MsgBox("Are you sure you want to remove this Product from Cart", MsgBoxStyle.YesNo, "Validation") = MsgBoxResult.Yes Then
Deleteitem()
loadbills()
gettotalitems()
totalamt()
clear()
txttotal.Text = ""
txtQuantity.Text = ""
End If
End Sub
Private Sub txtAmtPaid_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAmtPaid.TextChanged
txtBalance.Text = Val(lblTotalAmount.Text) - Val(txtAmtPaid.Text)
End Sub
Private Sub cmdpayment_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdpayment.SelectedIndexChanged
If cmdpayment.SelectedIndex = 1 Then
txtAmtPaid.Text = "0"
End If
End Sub
Private Sub btnreceipt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreceipt.Click
receipt.lblInvoice.Text = lblInvoice.Text
receipt.Show()
End Sub
End Class

Calling and executing a stored procedure from sql into a vb.net textbox

I have created the following stored procedure in SQL Server:
CREATE Procedure CalcTotal
#InvoiceID Varchar(4)
As
Declare #Total int
Begin
SELECT
#Total = (TransportFee + EquipmentFee + LabourFee)
FROM
Invoice
WHERE
InvoiceID = #invoiceID
UPDATE Invoice
SET Total = #Total
WHERE InvoiceID = #invoiceID
END
My code for my form on Visual Basic are:
Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class Invoice
Dim sqlConn As New SqlConnection With {.ConnectionString = "Data Source=Hamsheed;Initial Catalog=assignment;Integrated Security=True"}
Dim sqlstr As String = "Select * From Invoice"
Dim MaxRows As Integer
Dim RowIndex As Integer = 0
Dim dt As New DataTable
Private Sub Invoice_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim DataAdapter As New SqlDataAdapter(sqlstr, sqlConn)
DataAdapter.Fill(dt)
DataAdapter.Dispose()
MaxRows = dt.Rows.Count
InvoiceDetails()
cmbSearch.DataSource = dt
cmbSearch.DisplayMember = "FirstName"
End Sub
Sub InvoiceDetails()
txtInvoiceID.Text = CStr(dt.Rows(RowIndex)("InvoiceID"))
txtClientID.Text = CStr(dt.Rows(RowIndex)("ClientID"))
txtEmployeeID.Text = CStr(dt.Rows(RowIndex)("EmployeeID"))
txtFillInDate.Text = CStr(dt.Rows(RowIndex)("FillInDate"))
txtTransportFee.Text = CStr(dt.Rows(RowIndex)("TransportFee"))
txtEquipmentFee.Text = CStr(dt.Rows(RowIndex)("EquipmentFee"))
txtLabourFee.Text = CStr(dt.Rows(RowIndex)("LabourFee"))
txtTotal.Text = CStr(dt.Rows(RowIndex)("Total"))
End Sub
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
Dim InvoiceID As String = txtInvoiceID.Text
Dim ClientID As String = txtClientID.Text
Dim EmployeeID As String = (txtEmployeeID.Text)
Dim FillInDate As Date = CDate(txtFillInDate.Text)
Dim TransportFee As Integer = CInt(txtTransportFee.Text)
Dim EquipmentFee As Integer = CInt(txtEquipmentFee.Text)
Dim LabourFee As Integer = CInt(txtLabourFee.Text)
Dim Total As Integer = CInt(txtTotal.Text)
If CStr(dt.Rows(RowIndex)("paymentmethod")) = "Card" Then
radCard.Select()
ElseIf CStr(dt.Rows(RowIndex)("paymentmethod")) = "Cash" Then
radCash.Select()
Else
radCredit.Select()
End If
Dim sqlQuery As String = ("Exec Insert_Invoice #InvoiceID = ' " & InvoiceID & " ', #ClientID = '" & ClientID & "',#EmployeeID ='" & EmployeeID & "', #FillInDate ='" & FillInDate & "',#TransportFee='" & TransportFee & "',#EquipmentFee = '" & EquipmentFee & "',#LabourFee= '" & LabourFee & "',#Total= '" & Total)
Dim sqlcmnd As New SqlCommand(sqlQuery, sqlConn)
Try
sqlConn.Open()
Dim changes As Integer = sqlcmnd.ExecuteNonQuery()
sqlConn.Close()
MessageBox.Show(changes & "Changes Made")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Save()
End Sub
Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
dt.Rows(RowIndex)("InvoiceID") = CStr(txtInvoiceID.Text)
dt.Rows(RowIndex)("ClientID") = CStr(txtClientID.Text)
dt.Rows(RowIndex)("EmployeeID") = CStr(txtEmployeeID.Text)
dt.Rows(RowIndex)("FillInDate") = CStr(txtFillInDate.Text)
dt.Rows(RowIndex)("TransportFee") = CStr(txtTransportFee.Text)
dt.Rows(RowIndex)("EquipmentFee") = CStr(txtEquipmentFee.Text)
dt.Rows(RowIndex)("LabourFee") = CStr(txtLabourFee.Text)
dt.Rows(RowIndex)("Total") = CStr(txtTotal.Text)
Dim sqlquery As String = "exec edit_invoice '" & txtInvoiceID.Text & "', " & txtLabourFee.Text & ", " & txtTransportFee.Text & ", " & txtEquipmentFee.Text & ", '" & txtpaymentMethod.Text & "', '" & txtClientID.Text & "', '" & txtEmployeeID.Text & "', '" & txtFillInDate.Text & "', '" & txtTotal.Text & "'"
Dim sqlcmnd As New SqlCommand(sqlquery, sqlConn)
Try
sqlConn.Open()
Dim changes As Integer = sqlcmnd.ExecuteNonQuery()
sqlConn.Close()
MessageBox.Show(changes & "Changes Made")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Save()
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
txtInvoiceID.Clear()
txtClientID.Clear()
txtEmployeeID.Clear()
txtFillInDate.Clear()
txtTransportFee.Clear()
txtEquipmentFee.Clear()
txtLabourFee.Clear()
txtTotal.Clear()
End Sub
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
If RowIndex <> MaxRows - 1 Then
RowIndex += 1
InvoiceDetails()
End If
End Sub
Private Sub btnLast_Click(sender As Object, e As EventArgs) Handles btnLast.Click
RowIndex = MaxRows - 1
InvoiceDetails()
End Sub
Private Sub btnMainMenu_Click(sender As Object, e As EventArgs) Handles btnMainMenu.Click
SecretaryMainMenu.Show()
Me.Hide()
End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
Dim invoiceID As String = txtInvoiceID.Text
Dim SqlQuery As String = ("EXECUTE Delete_Invoice #InvoiceID = '" & InvoiceID & "'")
Dim cmd As New SqlCommand(SqlQuery, sqlConn)
Try
sqlConn.Open()
Dim changes As Integer = cmd.ExecuteNonQuery()
sqlConn.Close()
MessageBox.Show(changes & "Record Deleted")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Save()
dt.Rows(RowIndex).Delete()
End Sub
Sub Save()
Dim dataAdapter As New SqlDataAdapter(sqlstr, sqlConn)
Dim commandbuilder As New SqlCommandBuilder(dataAdapter)
dataAdapter.Update(dt)
dataAdapter.Dispose()
End Sub
Private Sub btnFind_Click(sender As Object, e As EventArgs) Handles btnFind.Click
Dim searchitem As String = InputBox("Input Search invoice ID: ", "Search by ID")
Dim sresult As Boolean = False
searchitem = searchitem.Trim.ToUpper
For i As Integer = 0 To MaxRows - 1
If CStr(dt.Rows(i)("invoiceid")).ToUpper = searchitem Then
sresult = True
RowIndex = i
InvoiceDetails()
End If
Next
If sresult = False Then
MsgBox("No result found", MsgBoxStyle.OkOnly, "Information")
End If
End Sub
Private Sub txtinvoice_validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtInvoiceID.Validating
If Not txtInvoiceID.Text Like "I###" Then
e.Cancel = True
ErrorProvider1.SetError(txtInvoiceID, "Improper ID format")
End If
End Sub
Private Sub txtinvoice_validated(ByVal sender As Object, ByVal e As EventArgs) Handles txtInvoiceID.Validated
ErrorProvider1.SetError(txtInvoiceID, "")
End Sub
End Class
Now I want to call the stored procedure into the textbox Total, which will compute the 'transportFee, EquipmentFee and Labourfee' costs, and display the total into the textbox of txtTotal.Text
How do I write that piece of code?
use executescalar: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalar(v=vs.110).aspx
remember to set the commandtype property of the command to stored procedure

not accessible in this context because it is 'Private' [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I'm writing some code for a calculator and I keep getting this error. I have the math functions in another class but the variables from form1 are not accessible. Below is my code.
I've also tried changing my Dim variables to public but that also doesn't work.
Public Class Form1
'create a value to keep track of whether the calculation is complete so the calculator can revert to zero for new calculations
Dim state As Integer
'create values to store information on numbers and signs entered as well as the answer returned
Dim one As Double
Dim two As Double
Dim ans As Double
Dim sign As Char
Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'when "Return" or "Enter" Key is selected button 15 is clicked (seems to only work when textbox selected????)
Me.AcceptButton = Button15
'change the title of the form
Me.Text = "Simple Calculator"
'label the buttons logically
Button1.Text = "1"
Button2.Text = "2"
Button3.Text = "3"
Button4.Text = "4"
Button5.Text = "5"
Button6.Text = "6"
Button7.Text = "7"
Button8.Text = "8"
Button9.Text = "9"
Button10.Text = "0"
Button11.Text = "+"
Button12.Text = "-"
Button13.Text = "X"
Button14.Text = "/"
Button15.Text = "Calc"
Button16.Text = "About Me"
Button17.Text = "Clear"
'allows form to revcieve key events
Me.KeyPreview = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'create action when button 1 is clicked
'if state is 1 then previous calculation was solved, then clear textbox to allow for new input
If state = 1 Then
TextBox1.Text = ""
'insert 1 into textbox
Dim Int1 As Integer = 1
TextBox1.Text = TextBox1.Text & Int1
'return state of calculator to zero to designate that calculation has NOT been solved
state = 0
Else
'else insert 1 into textbox
Dim Int1 As Integer = 1
TextBox1.Text = TextBox1.Text & Int1
End If
End Sub
' the above function for each numbered button
Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int2 As Integer = 2
TextBox1.Text = TextBox1.Text & Int2
state = 0
Else
Dim Int2 As Integer = 2
TextBox1.Text = TextBox1.Text & Int2
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int3 As Integer = 3
TextBox1.Text = TextBox1.Text & Int3
state = 0
Else
Dim Int3 As Integer = 3
TextBox1.Text = TextBox1.Text & Int3
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int4 As Integer = 4
TextBox1.Text = TextBox1.Text & Int4
state = 0
Else
Dim Int4 As Integer = 4
TextBox1.Text = TextBox1.Text & Int4
End If
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int5 As Integer = 5
TextBox1.Text = TextBox1.Text & Int5
state = 0
Else
Dim Int5 As Integer = 5
TextBox1.Text = TextBox1.Text & Int5
End If
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int6 As Integer = 6
TextBox1.Text = TextBox1.Text & Int6
state = 0
Else
Dim Int6 As Integer = 6
TextBox1.Text = TextBox1.Text & Int6
End If
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int7 As Integer = 7
TextBox1.Text = TextBox1.Text & Int7
state = 0
Else
Dim Int7 As Integer = 7
TextBox1.Text = TextBox1.Text & Int7
End If
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int8 As Integer = 8
TextBox1.Text = TextBox1.Text & Int8
state = 0
Else
Dim Int8 As Integer = 8
TextBox1.Text = TextBox1.Text & Int8
End If
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int9 As Integer = 9
TextBox1.Text = TextBox1.Text & Int9
state = 0
Else
Dim Int9 As Integer = 9
TextBox1.Text = TextBox1.Text & Int9
End If
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int0 As Integer = 0
TextBox1.Text = TextBox1.Text & Int0
state = 0
Else
Dim Int0 As Integer = 0
TextBox1.Text = TextBox1.Text & Int0
End If
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
'create an action for when addition button is clicked
Try
'when button is clicked dim sign and text in textbox
sign = "+"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error" ' if error occurs return error in textbox
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
'repeat the above action for remainder of arithmic functions
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
Try
'when button is clicked dim sign and text in textbox
sign = "-"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error" ' if error occurs return error in textbox
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
Try
sign = "*"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error" ' if error occurs return error in textbox
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
Try
sign = "/"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error"
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
'run functions based on sign stored during calculation
Try
two = TextBox1.Text
If sign = "+" Then
Calculator2.Math.add()
ElseIf sign = "-" Then
Calculator2.Math.minus()
ElseIf sign = "*" Then
Calculator2.Math.multiply()
ElseIf sign = "/" Then
Calculator2.Math.divide()
End If
'if user attempts to divide by zero return divide by zero error in textbox
If TextBox1.Text = "Infinity" Then
TextBox1.Text = "Divide by Zero Error"
state = 1 'if error occurs return state to 1 to allow for new calculation
End If
Catch ex As Exception
TextBox1.Text = "Error"
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
'create message box that provides information about author
Dim msg = "Student Name: Emily Wong" & vbCrLf & "Student Number: 0692740" ' Define the message you want to see inside the message box.
Dim title = "About Me" ' Define a title for the message box.
Dim style = MsgBoxStyle.OkOnly ' make an ok button for the msg box
Dim response = MsgBox(msg, style, title)
End Sub
Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
'create a clear button to clear textboxes when clicked and reset state of calculator
TextBox1.Text = ""
state = 0
End Sub
And this is my other class
Public Class Math
Inherits Form1
'create funtions for add,sub, multiply, and divide features
Sub add()
ans = one + two 'creates calculation of the entered numbers
TextBox1.Text = ans 'returns answer into the textbox
state = 1 'returns state to 1 to show that calculation has occured
End Sub
Sub minus()
ans = one - two
TextBox1.Text = ans
state = 1
End Sub
Sub multiply()
ans = one * two
TextBox1.Text = ans
state = 1
End Sub
Sub divide()
ans = one / two
TextBox1.Text = ans
state = 1
End Sub
End Class
state is a private variable in Form1. You can't access from code outside of Form1. Your Math class cannot reference state. Remove the calls to state from the Math class code. An outside class should not be changing the state of another object in anycase.
Try this instead:
Public Class accounting
Dim Operand1 As Double
Dim Operand2 As Double
Dim [Operator] As String
These are the button from 1 - 0
Private Sub Button6_Click_1(sender As Object, e As EventArgs) Handles Button9.Click, Button8.Click, Button7.Click, Button6.Click, Button5.Click, Button4.Click, Button19.Click, Button12.Click, Button11.Click, Button10.Click
txtans.Text = txtans.Text & sender.text
End Sub
This button is for period/point
Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
If InStr(txtans.Text, ".") > 0 Then
Exit Sub
Else
txtans.Text = txtans.Text & "."
End If
End Sub
This button is for clear or "C" in calculator
Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
txtans.Text = ""
End Sub
These are for add,subtract,divide, and multiply
Private Sub Buttonadd_Click(sender As Object, e As EventArgs) Handles Button13.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "+"
End Sub
Private Sub Buttondivide_Click(sender As Object, e As EventArgs) Handles Button15.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "-"
End Sub
Private Sub Buttonsubtract_Click(sender As Object, e As EventArgs) Handles Button16.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "*"
End Sub
Private Sub Buttonmultiply_Click(sender As Object, e As EventArgs) Handles Button14.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "/"
End Sub
This button is for "=" sign
Private Sub Buttoneequal_Click(sender As Object, e As EventArgs) Handles Button17.Click
Dim Result As Double
Operand2 = Val(txtans.Text)
'If [Operator] = "+" Then
' Result = Operand1 + Operand2
'ElseIf [Operator] = "-" Then
' Result = Operand1 - Operand2
'ElseIf [Operator] = "/" Then
' Result = Operand1 / Operand2
'ElseIf [Operator] = "*" Then
' Result = Operand1 * Operand2
'End If
Select Case [Operator]
Case "+"
Result = Operand1 + Operand2
txtans.Text = Result.ToString("#,###.00")
Case "-"
Result = Operand1 - Operand2
txtans.Text = Result.ToString("#,###.00")
Case "/"
Result = Operand1 / Operand2
txtans.Text = Result.ToString("#,###.00")
Case "*"
Result = Operand1 * Operand2
txtans.Text = Result.ToString("#,###.00")
End Select
txtans.Text = Result.ToString("#,###.00")
End Sub
This button is for backspace effect.
Private Sub Buttondel_Click(sender As Object, e As EventArgs) Handles Button21.Click
If txtans.Text < " " Then
txtans.Text = Mid(txtans.Text, 1, Len(txtans.Text) - 1 + 1)
Else
txtans.Text = Mid(txtans.Text, 1, Len(txtans.Text) - 1)
End If
End Sub
Note that "txtans.text" is the textbox where the user inputs and where the output shows.

How can I end my loop?

I made a loop to show the balance when entered a name, but when I try to do it a second time. It doesn't return another output(messagebox). How can I end/restart the loop?
Public Class Form1
Dim intMax_Subscript As Integer = 7
Dim arrayNames(intMax_Subscript) As String
Dim arrayBalance(intMax_Subscript) As Double
Dim found As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CBO1.Items.Add("John One")
arrayNames(0) = CStr(CBO1.Items(0))
CBO1.Items.Add("Jack Two")
arrayNames(1) = CStr(CBO1.Items(1))
CBO1.Items.Add("John Three")
arrayNames(2) = CStr(CBO1.Items(2))
CBO1.Items.Add("Jack Four")
arrayNames(3) = CStr(CBO1.Items(3))
CBO1.Items.Add("John Five")
arrayNames(4) = CStr(CBO1.Items(4))
CBO1.Items.Add("Jack Six")
arrayNames(5) = CStr(CBO1.Items(5))
CBO1.Items.Add("John Seven")
arrayNames(6) = CStr(CBO1.Items(6))
CBO1.Items.Add("Jack Eight")
arrayNames(7) = CStr(CBO1.Items(7))
CBO2.Items.Add("235.50")
arrayBalance(0) = CDbl(CBO2.Items(0))
CBO2.Items.Add("78943.98")
arrayBalance(1) = CDbl(CBO2.Items(1))
CBO2.Items.Add("230781.10")
arrayBalance(2) = CDbl(CBO2.Items(2))
CBO2.Items.Add("78362.00")
arrayBalance(3) = CDbl(CBO2.Items(3))
CBO2.Items.Add("12097.20")
arrayBalance(4) = CDbl(CBO2.Items(4))
CBO2.Items.Add("89267.34")
arrayBalance(5) = CDbl(CBO2.Items(5))
CBO2.Items.Add("34959.06")
arrayBalance(6) = CDbl(CBO2.Items(6))
CBO2.Items.Add("559284.50")
arrayBalance(7) = CDbl(CBO2.Items(7))
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBalance.Click
Dim input As String = InputBox("Input a name")
Dim intcount As Integer = -1
Dim intSubscript As Integer = 0
Do While Not found And intcount < arrayNames.Length
If arrayNames(intSubscript) = input Then
found = True
MessageBox.Show("The balance of " & input & "'s is " & arrayBalance(intSubscript))
intSubscript = 0
intcount = -1
End If
intSubscript += 1
Loop
If Not arrayNames.Contains(input) Then
MessageBox.Show("Error: Name not found.")
End If
End Sub
You Need to reset the found to false after showing message box
If Not arrayNames.Contains(input) Then
MessageBox.Show("Error: Name not found.")
found = False
End If
you don't need the 'found' variable at all
Do While intcount < arrayNames.Length
If arrayNames(intSubscript) = input Then
MessageBox.Show("The balance of " & input & "'s is " & arrayBalance(intSubscript))
intSubscript = 0
Exit Do
End If
intSubscript += 1
Loop

my Graphic User Interface (GUI) is unable to produce my results from my coordinator VIA Zigbee (Wireless Connection)

Basically, I'm given a task to continue from the previous student. I have several sensors that will detect the Temperature, Humidity and Luminosity of the lab. These data from sensors will need to transmit to the Coordinator. I'm able to debug the program but unable to achieve the result as shown in GUI. The reading values are not able to transmit. Below is the code given by the previous student which they are able to achieve it.
What could be the problem?? I suspect that it could be the Serial Port Problem.
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Windows.Forms.DataGridView
Public Class frmGUI
Dim FromSerialPort
Dim dSet As New DataSet
Dim COORDINATOR0 = 0
Dim strData(0 To 1)
Dim data As String
Dim count As Integer = 0
Dim number As Integer
Dim data2 As String
Dim x As Integer = 0
Dim txt1 As Integer = 0
Dim txt2 As Integer = 0
Dim txt3 As Integer = 0
Dim txt4 As Integer = 0
Dim hour As String = 0
Dim min As String = 0
Dim sec As String = 0
Dim hour2 As String = 0
Dim min2 As String = 0
Dim sec2 As String = 0
Dim LumVal1 As Integer
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If SerialPort1.IsOpen Then
SerialPort1.Close()
End If
System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\Welcome.vbs")
strData(0) = "ZED02"
TSSL1.Text = Format(Now, "Short Date")
TSSL2.Text = "Welcome"
TSSL3.Text = Format(Now, "Long Time")
PictureBox1.Image = System.Drawing.Bitmap.FromFile( _
My.Application.Info.DirectoryPath & "\Capture.PNG")
txtCOM.Focus()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Dim intResponse As Integer
intResponse = MsgBox(" Are u sure u want to QUIT ??!!", vbYesNo + vbExclamation, "Quit")
If intResponse = vbYes Then
End
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myTimer.Tick
TSSL3.Text = Format(Now, "Long Time")
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myTimer.Tick
If count = 1 Then
sec = sec + 1
If sec = 10 Then
sec = 0
sec2 = sec2 + 1
If sec2 = 6 Then
sec2 = 0
min = min + 1
If min = 10 Then
min = 0
min2 = min2 + 1
If min2 = 6 Then
min2 = 0
hour = hour + 1
If hour = 10 Then
hour = 0
hour2 = 1
If hour = 4 And hour2 = 2 Then
hour = 0
hour2 = 0
End If
End If
End If
End If
End If
End If
TSSL2.Text = ("Connected : " + hour2 + hour + ":" + min2 + min + ":" + sec2 + sec)
End If
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
If txtCOM.Text = "" Then
'MsgBox("Please enter a COM port value", vbOKOnly & vbExclamation, "Error")
txtCOM.Text = "34"
Else
count = count + 1
End If
If (count = 1) Then
System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\Connected.vbs")
txtCOM.Enabled = False
If SerialPort1.IsOpen Then
SerialPort1.Close()
End If
SerialPort1.PortName = "COM" & txtCOM.Text ' for the coordinator
SerialPort1.BaudRate = 38400
SerialPort1.Parity = System.IO.Ports.Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = System.IO.Ports.StopBits.One
SerialPort1.RtsEnable = True
SerialPort1.Open()
hour = 0
min = 0
sec = 0
hour2 = 0
min2 = 0
sec2 = 0
lbl1.Text = " Reading Data . . ."
TextBox5.Text &= "Connected at: " + Format(Now, "Short Time") + vbNewLine + vbNewLine
btnConnect.Text = "Disconnect"
End If
If count = 2 Then
System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\Disconnected.vbs")
txtCOM.Enabled = True
count = 0
btnConnect.Text = " Connect "
SerialPort1.Close() 'Close our Serial Port
lbl1.Text = " Not Connected "
TSSL2.Text = "Disconnected"
TextBox5.Text &= "Disconnected at: " + Format(Now, "Short Time") + vbNewLine + vbNewLine
End If
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.TextBox5.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
data &= [text]
If InStr(data, "Data not received") Then
data = ""
TextBox5.Text = "Data lost" + vbNewLine
End If
If InStr(data, "Lab Location: S.429") Then
If InStr(data, "TemperatureValue:") Then
If InStr(data, "Humidityvalue:") Then
If InStr(data, "LuminosityValue:") Then
txt1 = 1
txt2 = 0
txt3 = 0
txt4 = 0
data2 = data
End If
End If
End If
End If
If InStr(data, "Lab Location: S.434") Then
If InStr(data, "Temperaturevalue:") Then
If InStr(data, "HumidityValue:") Then
If InStr(data, "LuminosityValue:") Then
txt2 = 1
txt1 = 0
txt3 = 0
txt4 = 0
data2 = data
End If
End If
End If
End If
If InStr(data, "Lab Location: S.439") Then
If InStr(data, "TemperatureValue:") Then
If InStr(data, "HumidityValue:") Then
If InStr(data, "LuminosityValue:") Then
txt3 = 1
txt1 = 0
txt2 = 0
txt4 = 0
data2 = data
End If
End If
End If
End If
If InStr(data, "Lab Location: S.449") Then
If InStr(data, "TemperatureValue:") Then
If InStr(data, "HumidityValue:") Then
If InStr(data, "LuminosityValue:") Then
txt4 = 1
txt1 = 0
txt2 = 0
txt3 = 0
data2 = data
End If
End If
End If
End If
If txt1 = 1 Then
TextBox1.Text &= data2
TextBox5.Text &= "Data received from S.429 at: " + Format(Now, "Short Time") + vbNewLine + vbNewLine
System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\data429.vbs")
txt1 = txt1 + 1
If txt1 = 2 Then
txt1 = 0
data = ""
End If
End If
If txt2 = 1 Then
TextBox2.Text &= data2
TextBox5.Text &= "Data received from S.434 at: " + Format(Now, "Short Time") + vbNewLine + vbNewLine
System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\data434.vbs")
txt2 = txt2 + 1
If txt2 = 2 Then
txt2 = 0
data = ""
End If
End If
If txt3 = 1 Then
TextBox3.Text &= data2
TextBox5.Text &= "Data received from S.439 at: " + Format(Now, "Short Time") + vbNewLine + vbNewLine
System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\data439.vbs")
txt3 = txt3 + 1
If txt3 = 2 Then
txt3 = 0
data = ""
End If
End If
If txt4 = 1 Then
TextBox4.Text &= data2
TextBox5.Text &= "Data received from S.449 at: " + Format(Now, "Short Time") + vbNewLine + vbNewLine
System.Diagnostics.Process.Start(My.Application.Info.DirectoryPath & "\data449.vbs")
txt4 = txt4 + 1
If txt4 = 2 Then
txt4 = 0
data = ""
End If
End If
End If
End Sub
Private Sub TextBox1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox1.Clear()
End Sub
Private Sub TextBox2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox2.Clear()
End Sub
Private Sub TextBox3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox3.Clear()
End Sub
Private Sub TextBox4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox4.Clear()
End Sub
Private Sub TextBox5ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox5.Clear()
End Sub
Private Sub AllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Select(TextBox1.Text.Length, 0)
TextBox1.ScrollToCaret()
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
TextBox2.Select(TextBox2.Text.Length, 0)
TextBox2.ScrollToCaret()
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
TextBox3.Select(TextBox3.Text.Length, 0)
TextBox3.ScrollToCaret()
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
TextBox4.Select(TextBox4.Text.Length, 0)
TextBox4.ScrollToCaret()
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
TextBox5.Select(TextBox5.Text.Length, 0)
TextBox5.ScrollToCaret()
End Sub
Private Sub S429ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S429ToolStripMenuItem.Click
TextBox1.Clear()
End Sub
Private Sub SToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SToolStripMenuItem.Click
TextBox2.Clear()
End Sub
Private Sub S439ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S439ToolStripMenuItem.Click
TextBox3.Clear()
End Sub
Private Sub S449ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S449ToolStripMenuItem.Click
TextBox4.Clear()
End Sub
Private Sub BackLogToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackLogToolStripMenuItem.Click
TextBox5.Clear()
End Sub
Private Sub AllToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllToolStripMenuItem1.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
MsgBox(" NYP SMART LAB " + vbNewLine + " By: Daniel and Mikaris ", vbQuestion, " About ")
End Sub
Private Sub HowToReadValuesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HowToReadValuesToolStripMenuItem.Click
MsgBox("Temperature value < 26*C = Aircon is on" + vbNewLine + "Luminosity value > 1 = Lights are on" + vbNewLine, vbQuestion, "How to read values")
End Sub
End Class