Multiple camera shots in vb - vb.net

See I have this simple vb.net codes that counts from 5 to 1 then says capture! I need to do this 4 consecutive times after the start button is clicked .. I tried a do until loop but it didn't work, I'm a newbie here so please help..
Public Class Form_welcome
Dim Count As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Count -= 1
Label2.Text = Count
If (Count = 0) Then
Timer1.Enabled = False
Label2.Hide()
Label3.Show()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Count = 5
Timer1.Enabled = True
Label2.Text = Count
Timer1.Interval = 1000
End Sub
End Class

something like this?
Public Class Form_welcome
Dim Count As Integer
Dim pictureCount as integer = 4
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Count -= 1
Label2.Text = Count
If (Count = 0) Then
pictureCount -=1
If pictureCount = 0 then
Timer1.Enabled = False
End If
'take a picture
Label2.Hide()
Label3.Show()
Count = 5
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Count = 5
Timer1.Enabled = True
Label2.Text = Count
Timer1.Interval = 1000
End Sub
End Class

Public Class Form_welcome
Dim Count As Integer
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Admin_Login.Show()
Me.Hide()
End Sub
Private Sub Form_welcome_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Application.Exit()
End Sub
Private Sub Form_welcome_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button4.Hide()
Button5.Hide()
Button6.Hide()
'Timer1.Enabled = True
'Label2.Text = Count
'Timer1.Interval = 1000
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Count -= 1
'Label2.Text = Count
If (Count = -1) Then
Timer1.Enabled = False
Label3.Show()
Label3.Hide()
Label2.Hide()
Button4.Show()
Button5.Show()
Button6.Show()
PictureBox4.Hide()
PictureBox3.Show()
pict1.Show()
pict2.Show()
pict3.Show()
pict4.Show()
Button2.Hide()
End If
If (Count Mod 3) = 0 Then
Label2.Text = "Captured!"
Else
Label2.Text = Count
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Count = 12
Timer1.Enabled = True
Label2.Text = Count
Label2.Show()
Timer1.Interval = 1000
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Application.Exit()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Button2.Show()
Button4.Hide()
Button5.Hide()
Button6.Hide()
PictureBox3.Hide()
pict1.Hide()
pict2.Hide()
pict3.Hide()
pict4.Hide()
PictureBox4.Show()
End Sub
End Class

Related

How can I increase the font size of the user's input by one every 2 seconds in the code below?

Public Class Form1
Dim mypicturebox As New PictureBox
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "hello " & TextBox1.Text
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Me.Label1.Text = "enter your name"
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mypicturebox.BackColor = Color.Red
mypicturebox.Width = 50
mypicturebox.Height = 50
mypicturebox.Left = 100
mypicturebox.Top = 100
Me.Controls.Add(mypicturebox)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim MyFont As New Font(TextBox1.Font.FontFamily, 12, FontStyle.Bold)
Dim size As Integer = 30
Me.Font = New Font(Me.Font.FontFamily, size)
Label1.Font = New Font(Label1.Font.FontFamily, size)
Label1.Font.Size = Label1.Font.Size + 1
End Sub
End Class
When I run the code, it says that the font size is read-only so I cannot change it.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 2000 '2 sec
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox1.Font = New Font(TextBox1.Font.FontFamily, TextBox1.Font.Size + 1)
End Sub

So I tried creating a checklist with points in vb.net

I'm still currently trying to create a checklist with points as a reference if you are unsure you have COVID-19. ex. "if you have 1 point then you are still fine"
Right now all checkboxes work except for one which is the second checkbox
Public Class Form1
Dim pts As Byte
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "You have " & pts
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If Me.CheckBox1.Checked = True Then
pts = pts + 1
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If Me.CheckBox2.Checked = True Then
pts = pts + 1
End If
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
If Me.CheckBox1.Checked = True Then
pts = pts + 98
End If
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CheckBox1.CheckState = 0
CheckBox2.CheckState = 0
CheckBox3.CheckState = 0
Label1.Text = ""
pts = 0
End Sub
End Class
I don't know what else I can do really
The total values are just added but not subtracted on un-check event. Just simply use Else statement to do so. Look at the following example:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If Me.CheckBox1.Checked = True Then
pts = pts + 1
Else
pts = pts - 1
End If
End Sub

Get highest value from scales and remove unnecessary words

I created a little program to get weight from scales via COM port. But then I turn on program. It's start to loop (creating long list) SV 0 KG in Label. And if weight increase it's also loop, for e.g. SV 0 KG, SV 50 KG, SV 48 KG, SV 0 KG and etc..
So my question is how to stop loop and always show one value?
And second question can I use Replace("SV", " ") or there is other better method?
Dim myPort As Array
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myPort = IO.Ports.SerialPort.GetPortNames()
cmbBaud.Items.Add(9600)
cmbBaud.Items.Add(19200)
cmbBaud.Items.Add(38400)
cmbBaud.Items.Add(57600)
cmbBaud.Items.Add(115200)
For i = 0 To UBound(myPort)
cmbPort.Items.Add(myPort(i))
Next
cmbPort.Text = cmbPort.Items.Item(0)
cmbBaud.Text = cmbBaud.Items.Item(0)
btnDisconnect.Enabled = False
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
SerialPort1.PortName = cmbPort.Text
SerialPort1.BaudRate = cmbBaud.Text
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.DataBits = 8
SerialPort1.Open()
btnConnect.Enabled = False
btnDisconnect.Enabled = True
End Sub
Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
SerialPort1.Close()
btnConnect.Enabled = True
btnDisconnect.Enabled = False
End Sub
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
SerialPort1.Write(txtTransmit.Text & vbCr)
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.rtbReceived.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.rtbReceived.Text &= [text]
End If
End Sub
Private Sub cmbPort_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPort.SelectedIndexChanged
If SerialPort1.IsOpen = False Then
SerialPort1.PortName = cmbPort.Text
Else
MsgBox("Valid only if port is Closed", vbCritical)
End If
End Sub
Private Sub cmbBaud_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBaud.SelectedIndexChanged
If SerialPort1.IsOpen = False Then
SerialPort1.BaudRate = cmbBaud.Text
Else
MsgBox("Valid only if port is Closed", vbCritical)
End If
End Sub
Private Sub rtbReceived_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtbReceived.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
rtbReceived.Text = " "
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SerialPort1.Write(txtTransmit.Text & vbCr)
End Sub

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!

VB.net Form unexpectingly terminating

Hi I have the following form but cant figureout why its upbrubtly terminiating when difrent buttons are clicked?
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub button1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
Dim TEST1 As Integer = System.IO.Directory.GetFiles("C:\test\test").Length
If TEST1 = 0 Then
Me.WebBrowser1.Navigate("http://www.hotmail.com")
End If
End Sub
Private Sub button1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave
Me.WebBrowser1.Navigate("http://WWW.facebook.com")
End Sub
Private Sub button2_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.MouseLeave
Me.WebBrowser1.Navigate("http://WWW.facebook.com")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.WebBrowser1.Navigate("file://C:\test\test")
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.WebBrowser1.Navigate("file://C:\test")
Button2.Enabled = False
Button1.Enabled = True
End Sub
Private Sub button2_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.MouseEnter
Dim TEST2 As Integer = System.IO.Directory.GetFiles("C:\test\test").Length
If TEST2 = 0 Then
Me.WebBrowser1.Navigate("http://www.hotmail.com")
End If
End Sub
The terms face book and hotmail are just random to keep company site private :)
I suspect the Mouse_Enter event and the Mouse_Leave events are not giving time to the webbrowser to fully load the document and maybe it is internally crashing.
Try checking if the webbrowser has finished working before navigating again and tell us:
Use
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Me.WebBrowser1.Navigate("http://www.google.com")
End if