Private Sub TblCustomerBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.TblCustomerBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.CustomerDataDataSet)
End Sub
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'CustomerDataDataSet.tblCustomer' table. You can move, or remove it, as needed.
Me.TblCustomerTableAdapter.Fill(Me.CustomerDataDataSet.tblCustomer)
End Sub
Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click
Try
TblCustomerBindingSource.EndEdit()
TblCustomerTableAdapter.Update(CustomerDataDataSet.tblCustomer)
MessageBox.Show("Registered successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
Form5.Show()
Me.Hide()
Form5.TblReservationBindingSource.AddNew()
Form5.Label2.Text = Customer_IDTextBox.Text
Form5.Label3.Text = FirstNameTextBox.Text & " " & LastNameTextBox.Text
Catch ex As Exception
MessageBox.Show("Error")
End Try
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
FirstNameTextBox.Text = ""
LastNameTextBox.Text = ""
Contact_NoTextBox.Text = ""
Email_AddressTextBox.Text = ""
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Form1.Show()
Me.Hide()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Date_Of_RegistrationTextBox.Text = Format(Now, "MM/dd/yyyy, hh:mm:ss tt")
End Sub
When I try to add a new record vb.net automatically display the primary key in a decrementing value but when I click register and check my ms access file it displays the correct value for my primary key.
Here's my program
Related
How if ComboBox selection then directly CheckBox unchecked?
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Me.TextBox1.Text = ""
Me.PopulateDataGridView()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
clearfiltercombobox()
PopulateDataGridView()
End Sub
Put Me.CheckBox1.Checked = False in your ComboBox handler
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Me.TextBox1.Text = ""
Me.CheckBox1.Checked = False
Me.PopulateDataGridView()
End Sub
I have set up a picturebox, where i drag and drop a picture. I also would like to know the name of this file. How can i do this?
Here is the current code below that handles the picture box:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.AllowDrop = True
End Sub
Private Sub pb_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Try
PictureBox1.Image = Image.FromFile(CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString)
Catch ex As Exception
MessageBox.Show("Error Doing Drag/Drop")
End Try
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub pb_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
So, I'm still learning Visual Basic so I'm not entirely sure what I should be searching for however I've just been given a task to make a cash machine simulation, nothing that I can submit for coursework it's just for fun. However I'm trying to find out how to block out any buttons until a button prior to it is pressed. For example, I have a button that simulates entering your credit card and then a progress bar. However, I want the buttons 1 - 9 to be blocked until the progress bar has finished. My current code is:
Public Class Form1
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtNumber.Text = txtNumber.Text & "1"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
barProgress.Increment(5)
If barProgress.Value = 100 Then
MsgBox("Please insert your pin into our secure system.")
End If
End Sub
Private Sub btnInsertCard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertCard.Click
Timer1.Start()
If btnInsertCard.Text = "Insert Your Card" Then
btnInsertCard.Text = "Please wait.."
End If
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtNumber.Text = txtNumber.Text & "2"
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtNumber.Text = txtNumber.Text & "3"
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtNumber.Text = txtNumber.Text & "4"
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtNumber.Text = txtNumber.Text & "5"
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtNumber.Text = txtNumber.Text & "6"
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtNumber.Text = txtNumber.Text & "7"
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtNumber.Text = txtNumber.Text & "8"
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtNumber.Text = txtNumber.Text & "9"
End Sub
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
txtNumber.Text = txtNumber.Text & "0"
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtNumber.Clear()
End Sub
End Class
Any help would be appreciated!
I think what you're wanting to use is the .Enabled property.
In the Form1_Load I'm setting the .Enabled property for all of the buttons to False.
Once the barProgress.Value = 100 I stop the timer and enable the first button.
Then in the click event for each button I set the .Enabled property for the next button to True.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim buttonArray = {btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn0}
For Each button In buttonArray
button.Enabled = False
Next
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtNumber.Text = txtNumber.Text & "1"
btn2.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
barProgress.Increment(5)
If barProgress.Value = 100 Then
Timer1.Stop()
btn1.Enabled = True
MsgBox("Please insert your pin into our secure system.")
End If
End Sub
Private Sub btnInsertCard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertCard.Click
Timer1.Start()
If btnInsertCard.Text = "Insert Your Card" Then
btnInsertCard.Text = "Please wait.."
End If
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtNumber.Text = txtNumber.Text & "2"
btn3.Enabled = True
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtNumber.Text = txtNumber.Text & "3"
btn4.Enabled = True
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtNumber.Text = txtNumber.Text & "4"
btn5.Enabled = True
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtNumber.Text = txtNumber.Text & "5"
btn6.Enabled = True
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtNumber.Text = txtNumber.Text & "6"
btn7.Enabled = True
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtNumber.Text = txtNumber.Text & "7"
btn8.Enabled = True
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtNumber.Text = txtNumber.Text & "8"
btn9.Enabled = True
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtNumber.Text = txtNumber.Text & "9"
btn0.Enabled = True
End Sub
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
txtNumber.Text = txtNumber.Text & "0"
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'txtNumber.Clear()
txtNumber.Text = Nothing
End Sub
End Class
*Edit - Sorry I read your question wrong somehow. Corrected my answer.
I've added a delete button to delete data from DataGridView and it deletes right away but I wanted to ask if you would like to delete before it deletes. How do I add this function to this button?
This is my code so far:
Private Sub Table_RKMBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.Table_RKMBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.RKM_System_dataDataSet)
End Sub
Private Sub Management_Window_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'RKM_System_dataDataSet.Table_RKM' table. You can move, or remove it, as needed.
Me.Table_RKMTableAdapter.Fill(Me.RKM_System_dataDataSet.Table_RKM)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Table_RKMBindingSource.AddNew()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Table_RKMBindingSource.EndEdit()
Table_RKMTableAdapter.Update(Me.RKM_System_dataDataSet.Table_RKM)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Table_RKMBindingSource.RemoveCurrent()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Table_RKMBindingSource.EndEdit()
Search_Window.Show()
Table_RKMTableAdapter.Update(Me.RKM_System_dataDataSet.Table_RKM)
Me.Close()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub Table_RKMDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Table_RKMDataGridView.CellContentClick
End Sub
Thank you.
You can use a message box:
On your Button3_Click event add the following code:
Dim answer as Integer
answer = MessageBox.Show("Your Message", "Your title", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If not answer = 6 then Table_RKMBindingSource.RemoveCurrent()
That should work :)
I am trying to implement a project in VB.NET wherein a user can see two browser window panes side by side. It is very similar to placing two browser windows side by side on the screen, one docking to the left side, and the other on the right side. Only in this case, there's only one application. I'm having the following problems with my code
On pressing enter, the browser is not navigating to the website for both the panes
The controls on the left pane are not working. Only the Go button works for the left pane.
Here is my code (can't post pictures yet):
Public Class Form1
Dim int As Integer = 0
Dim int1 As Integer = 0
Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
ToolStripProgressBar1.Maximum = e.MaximumProgress
ToolStripProgressBar1.Value = e.MaximumProgress
End Sub
Private Sub Loading1(ByVal sender1 As Object, ByVal e1 As Windows.Forms.WebBrowserProgressChangedEventArgs)
ToolStripProgressBar2.Maximum = e1.MaximumProgress
ToolStripProgressBar2.Value = e1.MaximumProgress
End Sub
Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
TextBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
End Sub
Private Sub Done1(ByVal sender1 As Object, ByVal e1 As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
TabControl2.SelectedTab.Text = CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
TextBox2.Text = CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homePage)
Dim Browser1 As New WebBrowser
TabControl2.TabPages.Add("New Page")
Browser1.Name = "Web Browser 2"
Browser1.Dock = DockStyle.Fill
TabControl2.SelectedTab.Controls.Add(Browser1)
AddHandler Browser1.ProgressChanged, AddressOf Loading1
AddHandler Browser1.DocumentCompleted, AddressOf Done1
int1 = int1 + 1
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homePage)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homePage)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs)
If e.KeyCode = Keys.Enter Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
End If
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homePage)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ToolStripStatusLabel1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).StatusText
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
Dim Browser1 As New WebBrowser
TabControl2.TabPages.Add("New Page")
TabControl2.SelectTab(int1)
Browser1.Name = "Web Browser 2"
Browser1.Dock = DockStyle.Fill
TabControl2.SelectedTab.Controls.Add(Browser1)
AddHandler Browser1.ProgressChanged, AddressOf Loading1
AddHandler Browser1.DocumentCompleted, AddressOf Done1
int1 = int1 + 1
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homePage)
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
If Not TabControl2.TabPages.Count = 1 Then
TabControl2.TabPages.RemoveAt(TabControl2.SelectedIndex)
TabControl2.SelectTab(TabControl2.TabPages.Count - 1)
int1 = int1 - 1
End If
End Sub
Private Sub TextBox2_KeyDown(sender As Object, e As KeyEventArgs)
If e.KeyCode = Keys.Enter Then
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox2.Text)
End If
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homePage)
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox2.Text)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
ToolStripStatusLabel2.Text = CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).StatusText
End Sub
End Class
I'm new here so I'm sorry if I missed out anything. Any help would be appreciated. Thank you.
EDIT: I tried implementing the same thing with a single pane, much like implementing a simple tabbed browser in Visual Studio 2013. Same result. Only GO button works, and enter key does not produce anything.
If e.KeyCode = Keys.Enter Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
End If
You only calling navigate in TabControl1 (or 2). You need to call all from each of the TextBoxX_KeyDown Handlers.
If e.KeyCode = Keys.Enter Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox2.Text)
End If