Compiling application only source available - vb.net

I'm trying to compile some code that I found for an Application that I want to use.
Now I've download VB.NET express created a new project and just replaced the code with the one I got, but this isn't creating the forms (textfields etc.) at all, so I can't compile it.
Is this normal ? What else do I have to do to be able to compile it.
This is the source code:
Public Class Form1
Dim psc As String
Dim pwchange As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not My.Settings.pw_save = "" Then
TextBox6.Text = My.Settings.pw_save
CheckBox2.CheckState = CheckState.Checked
End If
If Not My.Settings.new_pw_save = "" Then
TextBox7.Text = My.Settings.new_pw_save
CheckBox1.CheckState = CheckState.Checked
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("mainPagePart:verifyCaptcha").InnerText = TextBox5.Text
'Die 1. - 5. Zahlenkombi
WebBrowser1.Document.GetElementById("mainPagePart:rn1").InnerText = TextBox1.Text
WebBrowser1.Document.GetElementById("mainPagePart:rn2").InnerText = TextBox2.Text
WebBrowser1.Document.GetElementById("mainPagePart:rn3").InnerText = TextBox3.Text
WebBrowser1.Document.GetElementById("mainPagePart:rn4").InnerText = TextBox4.Text
'Button bestätigen
'WebBrowser1.Document.Forms(0).InvokeMember("submit")
'Passwort Eingabe
WebBrowser1.Document.GetElementById("mainPagePart:passField").InnerText = TextBox6.Text
'WebBrowser1.Document.GetElementById("mainPagePart:next").InvokeMember("submit")
'Abfrage ob richtige Captcha Eingabe
'WebBrowser1.Document.GetElementById("mainPagePart:next").SetAttribute("value", "Free")
WebBrowser1.Document.GetElementById("mainPagePart:next").Focus()
SendKeys.Send("{ENTER}")
psc = 1
'Dim wert As HtmlElement = WebBrowser1.Document.GetElementById("j_id66")
'MessageBox.Show(wert.InnerText)
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Me.WebBrowser1.Document.Window.ScrollTo(50, 342)
If psc = 1 Then
'Dim wert As HtmlElement = WebBrowser1.Document.GetElementById("j_id66")
' Dim wert As HtmlElement = WebBrowser1.Document.GetElementFromPoint()
'MessageBox.Show(wert.InnerText)
Me.WebBrowser1.Document.Window.ScrollTo(150, 310)
psc = 0
If WebBrowser1.DocumentText.Contains("Bei deinem PIN-Code und/oder Passwort ist ein Fehler aufgetreten. Bitte überprüfe die korrekte Eingabe des PIN-Codes oder Passworts.") Then
Label1.Text = "Pin oder Passwort Falsch"
psc = 0
Label1.ForeColor = Color.Red
Me.WebBrowser1.Document.Window.ScrollTo(100, 370)
'WebBrowser1.Navigate("https://customer.cc.at.paysafecard.com/psccustomer/GetWelcomePanelServlet?&language=de&javax.faces.ViewState=j_id1")
ElseIf WebBrowser1.DocumentText.Contains("Bei der Eingabe des PIN-Codes oder Passworts ist ein Fehler aufgetreten. Bitte korrigiere deine Eingabe. Hast du ein Passwort für diese paysafecard vergeben, kontaktiere bitte unser Service-Team.") Then
Label1.Text = "Pin oder Passwort Falsch"
psc = 0
Label1.ForeColor = Color.Red
Me.WebBrowser1.Document.Window.ScrollTo(100, 370)
'Abfrage ob richtige Pin-Code Eingabe
ElseIf WebBrowser1.DocumentText.Contains("Bitte korrigiere deine Eingabe") Then
Label1.Text = "Pin oder Passwort Falsch"
psc = 0
Label1.ForeColor = Color.Red
Me.WebBrowser1.Document.Window.ScrollTo(100, 370)
ElseIf WebBrowser1.DocumentText.Contains("Der eingegebene Text stimmt nicht mit dem Angezeigten überein.") Then
Label1.Text = "Captcha falsch"
Label1.ForeColor = Color.Red
psc = 0
Me.WebBrowser1.Document.Window.ScrollTo(120, 350)
'WebBrowser1.Navigate("https://customer.cc.at.paysafecard.com/psccustomer/GetWelcomePanelServlet?&language=de&javax.faces.ViewState=j_id1")
ElseIf WebBrowser1.DocumentText.Contains("Verfügbares Guthaben") Then
Label1.ForeColor = Color.Green
Label1.Text = "PSC OK"
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Document.GetElementById("tabForm:password").Focus()
SendKeys.Send("{ENTER}")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If WebBrowser1.DocumentText.Contains("passwordPage:passwordOld") And Not pwchange = 1 Then
WebBrowser1.Document.GetElementById("passwordPage:passwordOld").InnerText = TextBox6.Text
WebBrowser1.Document.GetElementById("passwordPage:password1").InnerText = TextBox7.Text
WebBrowser1.Document.GetElementById("passwordPage:password2").InnerText = TextBox7.Text
pwchange = 1
WebBrowser1.Document.GetElementById("passwordPage:submit").Focus()
SendKeys.Send("{ENTER}")
Label5.Text = "Das neue Passwort lautet:" & TextBox7.Text
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Document.GetElementById("tabForm:close").Focus()
SendKeys.Send("{ENTER}")
Label5.Text = ""
Label1.Text = ""
End Sub
Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
If TextBox8.TextLength = 16 Then
TextBox1.Text = TextBox8.Text.Substring(0, 4)
TextBox2.Text = TextBox8.Text.Substring(4, 4)
TextBox3.Text = TextBox8.Text.Substring(8, 4)
TextBox4.Text = TextBox8.Text.Substring(12, 4)
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.CheckState = CheckState.Checked Then
My.Settings.new_pw_save = TextBox7.Text
Else
My.Settings.new_pw_save = ""
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.CheckState = CheckState.Checked Then
My.Settings.pw_save = TextBox6.Text
Else
My.Settings.pw_save = ""
End If
End Sub
End Class

From a quick glance at the code you need to have a form that goes with the code to provide the UI for the application. If you design your own remember to use the events dialog and wire up each event that you need.

Related

How to put many Textbox in one If else statement

This is the question
=If the FN button
will be click, then it will display a message base on the status of the textbox1 control. For the MN button, if
the event is click then it will display a message base on the status of the textbox2 control. The LN button
was clicked then it will display a message base on the status of the textbox3 control. Lastly, if the Clear
button control will be click and any of the textbox control is not empty then it will clear all the textbox
controls, but if all textbox controls are empty then it will show a message that all textbox controls are empty.
this is my code
Public Class Form1
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Label1.Text = "First Name"
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
Label2.Text = "Middle Name"
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
Label3.Text = "Last Name"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Text = "FN"
If TextBox1.Text = vbNullString Then
MessageBox.Show("The First name is empty")
Else MessageBox.Show("The First name is " & TextBox1.Text)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button2.Text = "MN"
If TextBox2.Text = vbNullString Then
MessageBox.Show("The Middle name is empty")
Else : MessageBox.Show("The Middle name is " & TextBox2.Text)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Button3.Text = "LN"
If TextBox3.Text = vbNullString Then
MessageBox.Show("The Last name is empty")
Else : MessageBox.Show("The Last name is " & TextBox3.Text)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Button4.Text = "Clear"
If (TextBox1.Text) And (TextBox2.Text) = vbNullString Then
MessageBox.Show("Textbox control is empty")
Else : TextBox1.Clear()
End If
For Each txt As Control In Me.Controls.OfType(Of TextBox)()
txt.Text = ""
Next
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
End Class
My question is , how to work on clear button because i cant do it in Textbox2 and Textbox3 thankyou
Try something like this
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = String.Empty
End If
Next ctrl
Try to add Next txt to your For Each
So, you are asking about Button4_Click.
This is what I was about to suggest first, because clearing all text boxes whether they are empty or not, is faster than first checking and then clearing.
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
' Button4.Text = "Clear"
' If (TextBox1.Text) And (TextBox2.Text) = vbNullString Then
' MessageBox.Show("Textbox control is empty")
' Else : TextBox1.Clear()
' End If
For Each txt As Control In Me.Controls.OfType(Of TextBox)()
txt.Text = ""
Next
MessageBox.Show("Textbox controls are empty")
End Sub
But then, if the intention is to a) just clear all textboxes, without any message if any one has some text. b) show the message only if all are empty.
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
' Button4.Text = "Clear"
If (TextBox1.Text = vbNullString) And (TextBox2.Text = vbNullString) And (TextBox3.Text = vbNullString) Then
MessageBox.Show("Textbox controls are empty")
Else
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End If
or (if this works, VB6 is alien for me)
....
Else
For Each txt As Control In Me.Controls.OfType(Of TextBox)()
txt.Text = ""
Next
End If
End Sub
I'd use a List(Of TextBox) allowing you to leverage All and ForEach:
Public Class Form1
Private TBs As New List(Of TextBox)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TBs.AddRange({TextBox1, TextBox2, TextBox3})
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If TBs.All(Function(tb) tb.Text = "") Then
MessageBox.Show("All TextBoxes are empty!")
Else
TBs.ForEach(Sub(tb) tb.Clear())
End If
End Sub
End Class
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
' Button4.Text = "Clear"
If (TextBox1.Text = vbNullString) And (TextBox2.Text = vbNullString) And (TextBox3.Text = vbNullString) Then
MessageBox.Show("Textbox controls are empty")
Else
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End If
thanks sir Tom Brunberg, this code works for me :)

MS Access Query In VB.NET 2008

The below code works in this way: When I enter data inside my textboxes, they go straight to my database and then if I click up button on the numeric up and down, it will give me empty textboxes to put data on again.
If I click on the down button in the numeric up and down, it will show me the previous data I entered in their respective textboxes. That's exactly what I have been wanting to do, but the problem is it only updates the database (obviously because of the UPDATE query) and overwrites the previously saved data.
Is there anyway that I can still achieve the same result (the one I mentioned about still being able to see the data I entered previously by the use of the numeric up and down) but the data previously stored in the database will not be overwritten?
Imports System.Data.OleDb
Public Class Form1
Dim ds As DataSet
Dim da As OleDbDataAdapter
Dim tables As DataTableCollection
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.ShowDialog()
Form2.Dispose()
End Sub
Private Sub RadioButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.Click
Label1.Text = "1"
Button1.PerformClick()
End Sub
Private Sub RadioButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton2.Click
Label1.Text = "2"
Button1.PerformClick()
End Sub
Private Sub RadioButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton3.Click
Label1.Text = "3"
Button1.PerformClick()
End Sub
Private Sub RadioButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton4.Click
Label1.Text = "4"
Button1.PerformClick()
End Sub
Public Sub clear()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
TextBox1.Select()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
NumericUpDown1.Value = ComboBox1.SelectedIndex
Dim dr As DataRow
Dim i As Integer
If Integer.TryParse(ComboBox1.SelectedValue.ToString, i) Then
i = ComboBox1.SelectedValue - 1
End If
dr = ds.Tables(0).Rows(i)
TextBox1.Text = dr("Question").ToString
TextBox2.Text = dr("Answer1").ToString
TextBox3.Text = dr("Answer2").ToString
TextBox4.Text = dr("Answer3").ToString
TextBox5.Text = dr("Answer4").ToString
Label1.Text = dr("RightAnswer").ToString
Label8.Text = ComboBox1.Text
If Label1.Text = "1" Then
RadioButton1.Checked = True
ElseIf Label1.Text = "2" Then
RadioButton2.Checked = True
ElseIf Label1.Text = "3" Then
RadioButton3.Checked = True
ElseIf Label1.Text = "4" Then
RadioButton4.Checked = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.Open()
ds = New DataSet
tables = ds.Tables
da = New OleDbDataAdapter("Select * from [Questions]", con)
da.Fill(ds, "Questions")
Dim view1 As New DataView(tables(0))
With ComboBox1
.DataSource = ds.Tables("Questions")
.ValueMember = "ID"
.DisplayMember = "ID"
.SelectedIndex = 0
End With
con.Close()
ComboBox1.SelectedIndex = NumericUpDown1.Value
NumericUpDown1.Value = ComboBox1.SelectedIndex
NumericUpDown1.Maximum = ComboBox1.Items.Count - 1
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
ComboBox1.SelectedIndex = NumericUpDown1.Value
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
con.Open()
Dim update_user As New Data.OleDb.OleDbCommand("UPDATE Questions SET [Question]= #Q, [Answer1]= #A1, [Answer2]= #A2, [Answer3]= #A3, [Answer4]= #A4, [RightAnswer]= #RA WHERE ID = #ID;", con)
update_user.Parameters.AddWithValue("#Q", TextBox1.Text)
update_user.Parameters.AddWithValue("#A1", TextBox2.Text)
update_user.Parameters.AddWithValue("#A2", TextBox3.Text)
update_user.Parameters.AddWithValue("#A3", TextBox4.Text)
update_user.Parameters.AddWithValue("#A4", TextBox5.Text)
update_user.Parameters.AddWithValue("#RA", Label1.Text)
update_user.Parameters.AddWithValue("#ID", Label8.Text)
update_user.ExecuteNonQuery()
update_user.Dispose()
con.Close()
ds = New DataSet
tables = ds.Tables
da = New OleDbDataAdapter("Select * from [Questions]", con)
da.Fill(ds, "Questions")
End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
Button1.PerformClick()
End Sub
Private Sub TextBox2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyUp
Button1.PerformClick()
End Sub
Private Sub TextBox3_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox3.KeyUp
Button1.PerformClick()
End Sub
Private Sub TextBox4_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox4.KeyUp
Button1.PerformClick()
End Sub
Private Sub TextBox5_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox5.KeyUp
Button1.PerformClick()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
NumericUpDown1.Enabled = False
If NumericUpDown1.Value = NumericUpDown1.Value + 1 Then
NumericUpDown1.Enabled = True
NumericUpDown1.Value = NumericUpDown1.Value - 1
End If
Else
NumericUpDown1.Enabled = True
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
NumericUpDown1.Enabled = False
If NumericUpDown1.Value = NumericUpDown1.Value + 1 Then
NumericUpDown1.Value = NumericUpDown1.Value - 1
End If
Else
NumericUpDown1.Enabled = True
End If
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
NumericUpDown1.Enabled = False
If NumericUpDown1.Value = NumericUpDown1.Value + 1 Then
NumericUpDown1.Value = NumericUpDown1.Value - 1
End If
Else
NumericUpDown1.Enabled = True
End If
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
NumericUpDown1.Enabled = False
If NumericUpDown1.Value = NumericUpDown1.Value + 1 Then
NumericUpDown1.Value = NumericUpDown1.Value - 1
End If
Else
NumericUpDown1.Enabled = True
End If
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
NumericUpDown1.Enabled = False
If NumericUpDown1.Value = NumericUpDown1.Value + 1 Then
NumericUpDown1.Value = NumericUpDown1.Value - 1
End If
Else
NumericUpDown1.Enabled = True
End If
End Sub
End Class

Sending items to database and making a receipt in VB.NET

We have another IT project, and this time it's on VB.NET, it's actually going pretty good compared to the one we did on Java. So it's still a POS System, and I have six functions of the POS (for admins, and 4 for employees). Right now I'm almost done with the Cash Register function. I have a problem, though. The menu items are in buttons, and once you click a button, it appears in three listboxes (one for item name, quantity and price), and once a button is clicked more than once, it looks for the string with its name and updates the price and quantity. A keypad is adjacent to the buttons, for the input of the customer's payment. Once btnTransact is clicked, it checks for equality of the total amount and the amount paid. So it goes through if else statements and once everything is niff and dandy it shows that the transaction is completed in a message box.
I need the items in the listboxes to appear in either a form or a message box (if that's possible), but I don't know how. Also, I need the listbox items to be sent to a database, tbl_Invoice with columns "Invoice Number (autonumber)", "Invoice Date (there's a realtime clock in my POS)", "Product Code (in tbl_Products, each item has a specific item code", "Quantity", "Unit Price", "Employee ID (I have a log-in as well, and I need to get the Employee ID based on the logged-in user from tbl_Employees)". I will provide appendices.
Also, I have partially added a DisplayDeceipt sub just in case.
I'm sorry if I do not know a lot about VB.NET, only basic functions are being taught to us, and what they're asking from us is waaaay beyond basic. Your help is greatly appreciated. Thank you]1
Imports System.Data.OleDb
Public Class frmCR
Dim intTotal, intPlace As Integer
Dim quantCCS, quantSalad, quantKare, quantGarlic, quantAdobo, quantMushroom, quantAsul, quantDilaw, quantBasket, quantIslands As Integer
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtPaid.Text += btn1.Text
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtPaid.Text += btn2.Text
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtPaid.Text += btn3.Text
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtPaid.Text += btn4.Text
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtPaid.Text += btn5.Text
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtPaid.Text += btn6.Text
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtPaid.Text += btn7.Text
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtPaid.Text += btn8.Text
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtPaid.Text += btn9.Text
End Sub
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
txtPaid.Text += btn0.Text
End Sub
Private Sub btnDeci_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeci.Click
txtPaid.Text += btnDeci.Text
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtPaid.Clear()
End Sub
Private Sub btnCCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCCS.Click
quantCCS += 1
If quantCCS = 1 Then
lstItems.Items.Add("CAESALAD")
lstQuant.Items.Add(quantCCS)
lstPrice.Items.Add("160")
Else
intPlace = lstItems.FindStringExact("CAESALAD")
lstQuant.Items(intPlace) = (quantCCS)
lstPrice.Items(intPlace) += 160
End If
intTotal += 160
lblTotal.Text = intTotal
End Sub
Private Sub tmrCR_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCR.Tick
lblTime.Text = Format(Now, "MM-dd-yyyy hh:mm:ss")
End Sub
Private Sub frmCR_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tmrCR.Enabled = True
End Sub
Private Sub btnSalad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalad.Click
quantSalad += 1
If quantSalad = 1 Then
lstItems.Items.Add("BBFSALAD")
lstQuant.Items.Add(quantSalad)
lstPrice.Items.Add("160")
Else
intPlace = lstItems.FindStringExact("BBFSALAD")
lstQuant.Items(intPlace) = (quantSalad)
lstPrice.Items(intPlace) += 160
End If
intTotal += 160
lblTotal.Text = intTotal
End Sub
Private Sub btnKare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKare.Click
quantKare += 1
If quantKare = 1 Then
lstItems.Items.Add("KAREKARE")
lstQuant.Items.Add(quantKare)
lstPrice.Items.Add("210")
Else
intPlace = lstItems.FindStringExact("KAREKARE")
lstQuant.Items(intPlace) = (quantKare)
lstPrice.Items(intPlace) += 210
End If
intTotal += 210
lblTotal.Text = intTotal
End Sub
Private Sub btnGarlic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGarlic.Click
quantGarlic += 1
If quantGarlic = 1 Then
lstItems.Items.Add("TAPAO")
lstQuant.Items.Add(quantGarlic)
lstPrice.Items.Add("180")
Else
intPlace = lstItems.FindStringExact("TAPAO")
lstQuant.Items(intPlace) = (quantGarlic)
lstPrice.Items(intPlace) += 180
End If
intTotal += 180
lblTotal.Text = intTotal
End Sub
Private Sub btnAdobo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdobo.Click
quantAdobo += 1
If quantAdobo = 1 Then
lstItems.Items.Add("ADOBODILAW")
lstQuant.Items.Add(quantAdobo)
lstPrice.Items.Add("145")
Else
intPlace = lstItems.FindStringExact("ADOBODILAW")
lstQuant.Items(intPlace) = (quantAdobo)
lstPrice.Items(intPlace) += 145
End If
intTotal += 145
lblTotal.Text = intTotal
End Sub
Private Sub btnMushroom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMushroom.Click
quantMushroom += 1
If quantMushroom = 1 Then
lstItems.Items.Add("MUSHCHICKEN")
lstQuant.Items.Add(quantMushroom)
lstPrice.Items.Add("160")
Else
intPlace = lstItems.FindStringExact("MUSHCHICKEN")
lstQuant.Items(intPlace) = (quantMushroom)
lstPrice.Items(intPlace) += 160
End If
intTotal += 160
lblTotal.Text = intTotal
End Sub
Private Sub btnAsul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAsul.Click
quantAsul += 1
If quantAsul = 1 Then
lstItems.Items.Add("KNGASUL")
lstQuant.Items.Add(quantAsul)
lstPrice.Items.Add("35")
Else
intPlace = lstItems.FindStringExact("KNGASUL")
lstQuant.Items(intPlace) = (quantAsul)
lstPrice.Items(intPlace) += 35
End If
intTotal += 35
lblTotal.Text = intTotal
End Sub
Private Sub btnDilaw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDilaw.Click
quantDilaw += 1
If quantDilaw = 1 Then
lstItems.Items.Add("KNGDILAW")
lstQuant.Items.Add(quantDilaw)
lstPrice.Items.Add("35")
Else
intPlace = lstItems.FindStringExact("KNGDILAW")
lstQuant.Items(intPlace) = (quantAsul)
lstPrice.Items(intPlace) += 35
End If
intTotal += 35
lblTotal.Text = intTotal
End Sub
Private Sub btnBasket_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBasket.Click
quantBasket += 1
If quantBasket = 1 Then
lstItems.Items.Add("ICECRMBASKET")
lstQuant.Items.Add(quantBasket)
lstPrice.Items.Add("110")
Else
intPlace = lstItems.FindStringExact("ICECRMBASKET")
lstQuant.Items(intPlace) = (quantAsul)
lstPrice.Items(intPlace) += 110
End If
intTotal += 110
lblTotal.Text = intTotal
End Sub
Private Sub btnIslands_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIslands.Click
quantIslands += 1
If quantIslands = 1 Then
lstItems.Items.Add("TSOKOISLAND")
lstQuant.Items.Add(quantIslands)
lstPrice.Items.Add("180")
Else
intPlace = lstItems.FindStringExact("TSOKOISLAND")
lstQuant.Items(intPlace) = (quantIslands)
lstPrice.Items(intPlace) += 180
End If
intTotal += 180
lblTotal.Text = intTotal
End Sub
Private Sub btnTransact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransact.Click
Dim intAmount, intPricePaid, intLack, intSuffice As Integer
If txtPaid.Text <> "" Or (lstItems.Items.Count = -1) Then
intAmount = lblTotal.Text
intPricePaid = txtPaid.Text
If intAmount > intPricePaid Then
intLack = intAmount - intPricePaid
Do
intSuffice = InputBox("Insufficient amount paid. Please ask Php " & intLack & "." & vbNewLine & "Enter amount:", "Insufficient Amount", MessageBoxButtons.OK, MessageBoxIcon.Error)
intLack = intLack - intSuffice
Loop While intLack > 0
If intLack = 0 Then
MessageBox.Show("Transaction Completed. There is no change. Here is your receipt.", "Transaction success", MessageBoxButtons.OK, MessageBoxIcon.Information)
lstItems.Items.Clear()
lstQuant.Items.Clear()
lstPrice.Items.Clear()
txtPaid.Text = ""
intTotal = 0
lblTotal.Text = "0.00"
ElseIf intLack < 0 Then
MessageBox.Show("Transaction Completed. The change is Php " & intLack * -1 & ". Here is your receipt.", "Transaction success", MessageBoxButtons.OK, MessageBoxIcon.Information)
lstItems.Items.Clear()
lstQuant.Items.Clear()
lstPrice.Items.Clear()
txtPaid.Text = ""
intTotal = 0
lblTotal.Text = "0.00"
End If
ElseIf intAmount = intPricePaid Then
MessageBox.Show("Transaction Completed. There is no change. Here is your receipt.", "Transaction success", MessageBoxButtons.OK, MessageBoxIcon.Information)
lstItems.Items.Clear()
lstQuant.Items.Clear()
lstPrice.Items.Clear()
txtPaid.Text = ""
intTotal = 0
lblTotal.Text = "0.00"
Else
MessageBox.Show("Transaction Completed. The change is Php " & intPricePaid - intAmount & ". Here is your receipt.", "Transaction success", MessageBoxButtons.OK, MessageBoxIcon.Information)
lstItems.Items.Clear()
lstQuant.Items.Clear()
lstPrice.Items.Clear()
txtPaid.Text = ""
intTotal = 0
lblTotal.Text = "0.00"
End If
ElseIf txtPaid.Text = "" Or (lstItems.Items.Count = -1) Then
MessageBox.Show("Please input a value.", "Null value", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Public Sub DisplayReceipt()
End Sub
End Class

OleDbException was unhandled [Newbie here]

i got error in this code please
i need this in school its a group project but im only doing this because they dont know how to code, so i participate to do this program, im a begginer in vb, i hope you understand, Thank you :)
Imports System.Data.OleDb
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form9
Private Sub Form9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'FoodDataSet.Table1' table. You can move, or remove it, as needed.
Table1BindingSource.AddNew()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked = True Then
TextBox1.Text = ("Burger P 12")
ElseIf RadioButton1.Checked = False Then
TextBox1.Text = ("Choose Your Order!")
End If
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked = True Then
TextBox1.Text = ("Cheese Burger = P 15")
ElseIf RadioButton2.Checked = False Then
TextBox1.Text = ("Choose Your Order!")
End If
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
If RadioButton3.Checked = True Then
TextBox1.Text = ("Ham Burger = P 15")
ElseIf RadioButton3.Checked = False Then
TextBox1.Text = ("Choose Your Order!")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
If RadioButton4.Checked = True Then
TextBox2.Text = ("Potato = P 10")
ElseIf RadioButton4.Checked = False Then
TextBox2.Text = ("Choose Your Order!")
End If
End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
If RadioButton5.Checked = True Then
TextBox2.Text = ("Piatos = P 12")
ElseIf RadioButton5.Checked = False Then
TextBox2.Text = ("Choose Your Order!")
End If
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
If RadioButton6.Checked = True Then
TextBox2.Text = ("Potato Fries = P 15")
ElseIf RadioButton6.Checked = False Then
TextBox2.Text = ("Choose Your Order!")
End If
End Sub
Private Sub RadioButton11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton11.CheckedChanged
If RadioButton11.Checked = True Then
TextBox3.Text = ("Coke = P 10")
ElseIf RadioButton11.Checked = False Then
TextBox3.Text = ("Choose Your Order!")
End If
End Sub
Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton8.CheckedChanged
If RadioButton8.Checked = True Then
TextBox3.Text = ("Sprite = P 10")
ElseIf RadioButton8.Checked = False Then
TextBox3.Text = ("Choose Your Order!")
End If
End Sub
Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton9.CheckedChanged
If RadioButton9.Checked = True Then
TextBox3.Text = ("Royal = P 10")
ElseIf RadioButton9.Checked = False Then
TextBox3.Text = ("Choose Your Order!")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim con As OleDbConnection
Table1BindingSource.AddNew()
MessageBox.Show("Your Orders in ongoing,Kindly Prepare your money and wait your order, Thank you!")
Me.Validate()
Me.Table1BindingSource.EndEdit()
con = New OleDbConnection("Provider=Microsoft.Ace.Oledb.12.0;Data Source=C:\Documents and Settings\WinXP\Desktop\LoadTest HP\WindowsApplication1\Food.mdb")
Me.Table1TableAdapter.Update(Me.FoodDataSet.Table1)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Table1BindingSource.RemoveCurrent()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton7.CheckedChanged
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Form10.Show()
Me.Close()
End Sub
End Class
It means you have a possible exception that wasn't handled you should handle the exception which will even show you a error which can further help you figure out what's wrong with your code :)
How do you handle exceptions? wrap code which uses OleDB with try/catch anywhere you use OleDb you should try/catch it.. remove the try/catch later when you know your code works 100%.
like so..
Try
con = New OleDbConnection("Provider=Microsoft.Ace.Oledb.12.0;Data Source=C:\Documents and Settings\WinXP\Desktop\LoadTest HP\WindowsApplication1\Food.mdb")
Catch ex as OleDbException
Msgbox ex.ToString()
End Try
I would wrap where you declare the OleDbConnection as well which is not necessary but it gets all the OleDb stuff in a try/catch
Try
Dim con As OleDbConnection
Table1BindingSource.AddNew()
MessageBox.Show("Your Orders in ongoing,Kindly Prepare your money and wait your order, Thank you!")
Me.Validate()
Me.Table1BindingSource.EndEdit()
con = New OleDbConnection("Provider=Microsoft.Ace.Oledb.12.0;Data Source=C:\Documents and Settings\WinXP\Desktop\LoadTest HP\WindowsApplication1\Food.mdb")
Catch ex as OleDbException
Msgbox ex.ToString()
End Try

String cannot be converted to System.Uri

Code:
Imports System
Imports System.IO
Imports System.Text
Public Class Browser
Dim Tab1Url As String = ""
Dim Tab2Url As String = ""
Dim TabNumber As Integer = 1
Dim DefaultHomePageSavedLocation As String = "C:\ToolBoxData\TinyBrowser\Home.txt"
Private Sub WebBrowser1_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
Label2.Text = "[BROWSER] Loading in Progress......"
ProgressBar1.Value = 50
End Sub
Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
WebBrowser1.GoBack()
Label2.Text = "[BROWSER] Going to Last History......"
ProgressBar1.Value = 0
End Sub
Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
'Next
WebBrowser1.GoForward()
Label2.Text = "[BROWSER] Going to Next History......"
ProgressBar1.Value = 0
End Sub
Private Sub HomeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HomeToolStripMenuItem.Click
'Home
Dim HomeLink As String = My.Computer.FileSystem.ReadAllText(DefaultHomePageSavedLocation)
WebBrowser1.Navigate(HomeLink)
Label2.Text = "[BROWSER] Going Home......"
ProgressBar1.Value = 0
End Sub
Private Sub ToolStripTextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTextBox1.Click
Label2.Text = "[USER] Inserting / Copying URL......"
End Sub
Private Sub GoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToolStripMenuItem.Click
If TabNumber = 1 Then
Tab1Url = ToolStripTextBox1.Text
WebBrowser1.Navigate(Tab1Url)
Button1.Text = ToolStripTextBox1.Text
ElseIf TabNumber = 2 Then
Tab2Url = ToolStripTextBox1.Text
WebBrowser1.Navigate(Tab2Url)
Button2.Text = ToolStripTextBox1.Text
End If
ProgressBar1.Value = 0
End Sub
Private Sub ReloadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReloadToolStripMenuItem.Click
WebBrowser1.Refresh()
Label2.Text = "[BROWSER] Refreshing......"
ProgressBar1.Value = 0
End Sub
Private Sub TinyBrowserV10ByToolBoxWeeblyComToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TinyBrowserV10ByToolBoxWeeblyComToolStripMenuItem.Click
WebBrowser1.Navigate("http://tool-box.weebly.com/")
Label2.Text = "[BROWSER] Redirecting to Our Website......"
ProgressBar1.Value = 0
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Label2.Text = "[BROWSER] Loading Completed."
ToolStripTextBox1.Text = WebBrowser1.Url.ToString
ProgressBar1.Value = 100
End Sub
Private Sub ToolStripTextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ToolStripTextBox1.KeyPress
If e.KeyChar = Chr(13) Then
If TabNumber = 1 Then
Tab1Url = ToolStripTextBox1.Text
WebBrowser1.Navigate(Tab1Url)
Button1.Text = ToolStripTextBox1.Text
ElseIf TabNumber = 2 Then
Tab2Url = ToolStripTextBox1.Text
WebBrowser1.Navigate(Tab2Url)
Button2.Text = ToolStripTextBox1.Text
End If
ProgressBar1.Value = 0
End If
End Sub
Private Sub Browser_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
If e.KeyChar = Convert.ToChar(Keys.Back) Then
WebBrowser1.GoBack()
ProgressBar1.Value = 0
End If
End Sub
Private Sub OptionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionToolStripMenuItem.Click
Setting.Show()
End Sub
Private Sub Browser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.FileSystem.FileExists(DefaultHomePageSavedLocation) = False Then
My.Computer.FileSystem.CreateDirectory("C:\ToolBoxData\TinyBrowser\")
My.Computer.FileSystem.WriteAllText(DefaultHomePageSavedLocation, "http://hk.yahoo.com", True)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not TabNumber = 1 Then
TabNumber = 1
ChangeTab()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Not TabNumber = 2 Then
TabNumber = 2
ChangeTab()
End If
End Sub
Private Sub ChangeTab()
If TabNumber = 1 Then
WebBrowser1.Url = Tab1Url
ElseIf TabNumber = 2 Then
WebBrowser1.Url = Tab2Url
End If
End Sub
End Class
And the error is:
Value of type "String" cannot be converted to "System.Uri" (Line 121, 123)
What's the problem?
I've found the solution at another website.
Solution:
Line 121:
WebBrowser1.Url = New Uri(Tab1Url)
Line 123:
WebBrowser1.Url = New Uri(Tab2Url)
Thanks for all your help!