Wont insert data to Access Database, keep stuck on Open Connection - visual-studio-2010

I create a Learning Aplication for English kindergarten, and I got stuck on the editing form for insert data about sing a song...
Here's my program view:
Editing Learning
Translate
Tambah = Add
Ubah = Edit
Simpan = Save
Batal = Cancel
Hapus = Delete
Cari = Find
Now the problem is, when i click SIMPAN (SAVE), nothing happened, i try click SAVE again, show up an error like this
The Connection wasn't closed
Here's the coding:
Public Class frmeditlearning
Dim baru, valid As String
Dim id1, judul1, video1, databaru As String
Dim cmd1 As New OleDbCommand(databaru, mycon)
Private Sub btntambahsing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntambahsing.Click
'This is button for ADD when get clicked
txtjudul.Enabled = True
txtvideo.Enabled = True
txtid.Clear()
txtid.Select()
btnsingcarivideo.Enabled = True
btnsimpansing.Enabled = True
btnbatalsing.Enabled = True
btnubahsing.Enabled = False
btnhapussing.Enabled = False
baru = True
btntambahsing.Enabled = False
End Sub
Private Sub btnsimpansing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpansing.Click
If txtid.Text = "" Or txtjudul.Text = "" Or txtvideo.Text = "" Then
MessageBox.Show("Empty textbox is not allowed!", "EMPTY TEXTBOX", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
If baru = True Then
mycon.Open()
Dim noid, str As String
str = "Select id from sing where (id = '" & txtid.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, mycon)
dr = cmd.ExecuteReader
While dr.Read
noid = dr("id").ToString
If txtid.Text = noid Then
mycon.Close()
MessageBox.Show("SAME ID CANNOT USED!", "DUPLICATE ID", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
Else
If Not (txtid.Text = noid) Then
mycon.Open()
id1 = txtid.Text
judul1 = txtjudul.Text
video1 = txtvideo.Text
databaru = "INSERT INTO sing (id,judul,video) values(#id,#judul,#video)"
cmd1.Parameters.AddWithValue("#id", id1)
cmd1.Parameters.AddWithValue("#judul", judul1)
cmd1.Parameters.AddWithValue("#video", video1)
cmd1.ExecuteNonQuery()
mycon.Close()
btnbatalsing.PerformClick()
End If
End If
End While
End If
End Sub
Thanks in advance, sorry if my English is bad.

Related

Combobox by any contain

i am trying to filter combobox by any contain but it not happening
Private Sub cboServicename()
Try
Dim myConnToAccess As OleDb.OleDbConnection = MyDBmodule()
myConnToAccess.Open()
Dim ds = New DataSet
Dim tables = ds.Tables
Dim da = New OleDb.OleDbDataAdapter("SELECT Distinct service_name from Services_Data ", myConnToAccess)
da.Fill(ds, "Services_Data")
Dim view1 As New DataView(tables(0))
With auditmodule_Servicename
.DataSource = ds.Tables("Services_Data")
.DisplayMember = "service_name"
.ValueMember = "service_code"
.SelectedIndex = 0
End With
Catch ex As Exception
End Try
End Sub

Is there anyway to alert the user when a timer is already running?

I'm creating a computer rental system and what I want to happen is:
User chooses to use PC 1, Timer triggers and PC 1 will be in use, Another user logs in and selects PC, System notifies user that PC 1 is in use and wont accept their input.
Here's the code for the timer:
Public Class Time1
Private DT As DateTime
Private Countdown As TimeSpan = TimeSpan.FromHours(1)
Dim ans As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Button3.Enabled = False
Timer1.Interval = 1000
DT = DateTime.Now.Add(Countdown)
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim ts As TimeSpan = DT.Subtract(DateTime.Now)
If ts.TotalMilliseconds > 0 Then
Label2.Text = ts.ToString("hh\:mm\:ss")
Button3.Enabled = False
Else
Label2.Text = "00:00:00"
Timer1.Stop()
MessageBox.Show("Time's up! You can now extend your time or end your session.")
Button3.Enabled = True
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If Timer1.Enabled Then
Dim result As DialogResult = MessageBox.Show("You still have some time left. Are you sure you want to end your session now? Payment will not be reducted!", _
"End Time?", _
MessageBoxButtons.YesNo)
If (result = DialogResult.Yes) Then
Timer1.Stop()
Close()
Else
Return
End If
End If
End Sub
End Class
Here's the code for the rental page:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Hide()
Home1.Show()
End Sub
Private Sub Computer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Comp_RentalDataSet.tblcomp' table. You can move, or remove it, as needed.
Me.TblcompTableAdapter.Fill(Me.Comp_RentalDataSet.tblcomp)
conn.ConnectionString = dbProvider & dbSource
conn.Open()
GetRecords()
Me.Label3.Text = DateTime.Now.ToLongDateString
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ds = New DataSet
adapter = New OleDbDataAdapter("insert into [tblcomp] ([Comp_ID], [User_ID], [Date_Today],[No_of_Hours], [Total_Payment]) VALUES " & "('" & ComboBox1.Text & "','" & TextBox2.Text & "','" & Label3.Text & "','" & ComboBox2.Text & "','" & Label2.Text & "')", conn)
strsql = ("SELECT User_ID FROM tblusers WHERE User_ID='" + TextBox2.Text + "'")
Dim cmd As New OleDbCommand(strsql, conn)
reader = cmd.ExecuteReader
If (reader.HasRows) Then
adapter.Fill(ds, "tblcomp")
TextBox2.Clear()
ComboBox1.ResetText()
ComboBox2.ResetText()
Label2.ResetText()
GetRecords()
MessageBox.Show("Computer has been rented!")
ElseIf (ComboBox1.Text = "" Or ComboBox2.Text = "" Or TextBox2.Text = "") Then
MessageBox.Show("Please fill in the empty fields!")
Else
MessageBox.Show("The User ID is not recognized! Check your input for errors.")
End If
Label2.ResetText()
If ComboBox2.SelectedItem Is "1" Then
Time1.Show()
ElseIf ComboBox2.SelectedItem Is "2" Then
Time2.Show()
ElseIf ComboBox2.SelectedItem Is "3" Then
Time3.Show()
ElseIf ComboBox2.SelectedItem Is "4" Then
Time4.Show()
ElseIf ComboBox2.SelectedItem Is "5" Then
Time5.Show()
ElseIf ComboBox2.SelectedItem Is "6" Then
Time6.Show()
ElseIf ComboBox2.SelectedItem Is "7" Then
Time7.Show()
ElseIf ComboBox2.SelectedItem Is "8" Then
Time8.Show()
ElseIf ComboBox2.SelectedItem Is "9" Then
Time9.Show()
ElseIf ComboBox2.SelectedItem Is "10" Then
Time10.Show()
ElseIf ComboBox2.SelectedItem Is "11" Then
Time11.Show()
ElseIf ComboBox2.SelectedItem Is "12" Then
Time12.Show()
End If
If ComboBox2.SelectedItem Is "1" And Time1.Enabled Or Time2.Enabled Or Time3.Enabled Or Time4.Enabled Or Time5.Enabled Or Time6.Enabled Or Time7.Enabled Or Time8.Enabled Or Time9.Enabled Or Time10.Enabled Or Time11.Enabled Or Time12.Enabled Then
MessageBox.Show("This PC is already in use!")
End If
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
price = Convert.ToInt32(ComboBox2.SelectedItem)
Label2.Text = CStr(price * 15)
End Sub
Public Sub GetRecords()
ds = New DataSet
adapter = New OleDbDataAdapter("select * from [tblcomp]", conn)
adapter.Fill(ds, "tblcomp")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "tblcomp"
End Sub
End Class
At first, I tried a code like this:
If ComoBox.SelectedItem Is "1" And Time1.Enabled Then
MessageBox.Show("This PC is already in use!")
End If
But the message box pops up, even when its the first time the user selects PC 1. Is there anyway the system can notify the user only when a specific item in my combo box is selected the second time and timer is still running for it? (Oh yeah, before anyone asks, Time1, Time2, etc. are seperate timers for the individual hours of 1-12. I think there's a faster and more efficient way of doing this, but I dont know how)

Need help fixing Exception Unhandled

I am getting the following error:
System.ArgumentOutOfRangeException: 'Index and length must refer to a location within the string.
Parameter name: length'
(Look for Bold Italic on code *** that's where it is taking me to fix that)
Not sure what the problem is. Here is the whole code:
Imports GroceryApp.GroceryItem
Imports System.IO
Public Class GroceryItemForm
Private strFileName As String = String.Empty
Private Sub btnAddToBasket_Click(sender As Object, e As EventArgs) Handles btnAddToBasket.Click, AddToolStripMenuItem.Click
Dim gi As GroceryItem
Dim price As Double
' Validate that brand name is entered
If txtBrandName.Text = "" Then
MsgBox("Please input an Brand Name", , "Value Required")
txtBrandName.Focus()
Exit Sub
End If
' Validate that price is entered
If Not Double.TryParse(numPrice.Text, price) Then
MsgBox("Please input an Price", , "Value Required")
numPrice.Focus()
Exit Sub
End If
' Validate that Aisle is selected
If cboAisle.Text = "" Then
MsgBox("Please select an Aisle", , "Value Required")
cboAisle.Focus()
Exit Sub
End If
***txtScanNumber.Text = txtBrandName.Text.Substring(0, 3) & "1019"***
gi = New GroceryItem(txtScanNumber.Text, txtBrandName.Text, price)
gi.Type = [Enum].Parse(GetType(Aisle), cboAisle.Text)
gi.Description = txtDescription.Text
basket.Add(gi)
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub ViewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ViewToolStripMenuItem.Click
'Dim result As String = ""
'Dim i As Integer = 1
'For Each gi As GroceryItem In basket
'result = result & "Item " & i & vbNewLine & "Aisle: " & gi.Type.ToString & vbNewLine & "Scan Number: " & gi.ScanNumber & vbNewLine & "Brand Name: " & gi.BrandName & vbNewLine & vbNewLine
'i = i + 1
'Next
'MsgBox(result, , "Basket Details")
Dim oForm As BasketDisplayForm
oForm = New BasketDisplayForm()
oForm.Show()
oForm = Nothing
End Sub
Private Sub GroceryItemForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oForm As LoginForm
oForm = New LoginForm()
oForm.Show()
oForm = Nothing
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
Dim rowLine As String = ""
'If strFileName = String.Empty Then
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
strFileName = SaveFileDialog1.FileName
Dim fsStream As New FileStream(strFileName, FileMode.Append, FileAccess.Write)
Dim sw As New StreamWriter(fsStream)
Dim sb As New System.Text.StringBuilder
For Each Item As GroceryItem In basket
sb.AppendLine(String.Concat(Item.ScanNumber, ",", Item.Type.ToString, ",", Item.BrandName, ",", Item.Description, ",", Item.Price))
'rowLine = rowLine + Item.ScanNumber + "," + Item.Type.ToString + "," + Item.BrandName + "," + Item.Description + "," + Item.Price.ToString
Next
'IO.File.WriteAllText(strFileName, sb.ToString)
'rowLine = rowLine.Remove(rowLine.Length - 1, 1)
sw.WriteLine(sb)
sw.Flush()
MsgBox("Data Saved Successfully")
sw.Close()
basket.Clear()
End If
'End If
End Sub
Private Sub LoadToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadToolStripMenuItem.Click
Dim basketFile As StreamReader
Dim gi As GroceryItem
Dim sNo, brand, desc, aisle As String
Dim price As Double
Dim y As Integer
basket.Clear()
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
strFileName = OpenFileDialog1.FileName
basketFile = File.OpenText(strFileName)
' Read Power rating from file
Using sr As StreamReader = New StreamReader(strFileName)
Do While sr.Peek() > -1
For Each c As String In sr.ReadToEnd().Split(CType(Chr(10), Char))
sNo = ""
For Each d As String In c.Split(",")
If y = 0 Then
sNo = d
End If
If y = 1 Then
aisle = d
End If
If y = 2 Then
brand = d
End If
If y = 3 Then
desc = d
End If
If y = 4 Then
price = d
End If
y += 1
Next
If (sNo <> "") Then
gi = New GroceryItem(sNo, brand, price)
gi.Type = [Enum].Parse(GetType(Aisle), aisle)
gi.Description = desc
If (sNo <> "" & vbCr & "") Then
basket.Add(gi)
End If
End If
y = 0
Next
Loop
End Using
basketFile.Close()
End If
End Sub
End Class

Visual Studio 2010 String.Format exception

Im trying to insert column to a listbox using format.string but it seems to be not working, "Input string was not in correct format" it says. I have ran out of ideas to solve this problem, can't really find any solution on google. So I decided to ask here, btw here's my code
Public Class Form1
Dim stddetails As String = "{0, -20}{1, -20}{2, -20}{3, -20}(4, -20}{5, -20}{6, -20}"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lstoutput.Items.Add(String.Format(stddetails, "Customer ID", "Nama Depan", "Nama Belakang", "Pemesanan", "Tanggal Pemesanan", "Pembayaran", "Total"))
cmbpemesanan.Items.Add("Pilih Cara Pemesanan")
cmbpemesanan.Items.Add("Telepon")
cmbpemesanan.Items.Add("Ditempat")
cmbpemesanan.Items.Add("Pemesanan Online")
cmbpembayaran.Items.Add("Pilih Pembayaran")
cmbpembayaran.Items.Add("Cash")
cmbpembayaran.Items.Add("Master Card")
cmbpembayaran.Items.Add("Visa Card")
cmbpembayaran.Items.Add("Debit Langsung")
lstmerek.Items.Add("Indonesian")
lstmerek.Items.Add("Japanese")
lstmerek.Items.Add("Middle East")
lstmerek.Items.Add("European")
seafood.Checked = False
traditional.Checked = False
drinks.Checked = False
fullpack.Checked = False
rbsatu.Checked = False
rbdua.Checked = False
rbempat.Checked = False
rbdelapan.Checked = False
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
Dim ikeluar As DialogResult
ikeluar = MessageBox.Show("Keluar dari menu?", "Food Order Menu", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If ikeluar = DialogResult.Yes Then
Application.Exit()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
seafood.Checked = False
traditional.Checked = False
drinks.Checked = False
fullpack.Checked = False
rbsatu.Checked = False
rbdua.Checked = False
rbempat.Checked = False
rbdelapan.Checked = False
txtid.Clear()
txtnamabelakang.Clear()
txtnamadepan.Clear()
cmbpembayaran.Text = "Pilih Pembayaran"
cmbpemesanan.Text = "Pilih Cara Pemesanan"
lstoutput.Items.Clear()
lstmerek.SelectedItems.Clear()
lstoutput.Items.Add(String.Format(stddetails, "Customer ID", "Nama Depan", "Nama Belakang", "Pemesanan", "Tanggal Pemesanan", "Pembayaran", "Total"))
End Sub
Public Function getprices(ByVal brand As String, ByVal items As List(Of String), ByVal quantity As Integer) As Double
Dim prices = {
{"Indonesian", 2.5, 2, 0.95},
{"Japanese", 2.3, 1.5, 2.5},
{"Middle East", 3.5, 5, 4.9},
{"European", 3.8, 2.7, 1.5}
}
Dim sum As Double = 0
For i As Integer = 0 To 4
If (brand = prices(i, 0)) Then
For j As Integer = 0 To items.Count - 1
If (items(j) = "Seafood") Then
sum = sum + prices(i, 1)
ElseIf (items(j) = "Traditional") Then
sum = sum + prices(i, 2)
ElseIf (items(j) = "Drinks") Then
sum = sum + prices(i, 3)
End If
Next
sum = sum * quantity
End If
Next
Return sum
End Function
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
Dim ID, namadepan, namabelakang, pemesanan, tanggal, pembayaran, price As String
ID = txtid.Text
namadepan = txtnamadepan.Text
namabelakang = txtnamabelakang.Text
pemesanan = cmbpemesanan.Text
tanggal = cmbtanggal.Text
pembayaran = cmbpembayaran.Text
Dim items As New List(Of String)
Dim quantity As Integer
If (seafood.Checked = True) Then
items.Add(seafood.Text)
End If
If (traditional.Checked = True) Then
items.Add(traditional.Text)
End If
If (drinks.Checked = True) Then
items.Add(drinks.Text)
End If
If (fullpack.Checked = True) Then
items.Add(fullpack.Text)
End If
If (rbsatu.Checked = True) Then
quantity = 1
ElseIf (rbdua.Checked = True) Then
quantity = 2
ElseIf (rbempat.Checked = True) Then
quantity = 4
ElseIf (rbdelapan.Checked = True) Then
quantity = 8
End If
If lstmerek.Text = "" Then
MessageBox.Show("Anda harus memilih jenis makanan.", "Jenis Makanan", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf (seafood.Checked = False And traditional.Checked = False And drinks.Checked = False) Then
MessageBox.Show("Anda harus memilih kategori.", "Kategori", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf (rbsatu.Checked = False And rbdua.Checked = False And rbempat.Checked = False And rbdelapan.Checked = False) Then
MessageBox.Show("Anda harus memilih jumlah.", "Jumlah Pesanan", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
price = FormatCurrency(getprices(lstmerek.Text, items, quantity))
lstoutput.Items.Add(String.Format(stddetails, ID, namadepan, namabelakang, pemesanan, tanggal, pembayaran, price))
End If
End Sub
Private Sub btntambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntambah.Click
seafood.Checked = False
traditional.Checked = False
drinks.Checked = False
fullpack.Checked = False
rbsatu.Checked = False
rbdua.Checked = False
rbempat.Checked = False
rbdelapan.Checked = False
txtid.Clear()
txtnamabelakang.Clear()
txtnamadepan.Clear()
cmbpembayaran.Text = "Pilih Pembayaran"
cmbpemesanan.Text = "Pilih Cara Pemesanan"
lstoutput.Items.Clear()
lstmerek.SelectedItems.Clear()
End Sub
End Class
Any help would be much appreciated, thanks.
There's a syntax error on line 2
You used a "(" instead of "{"
Replace
Dim stddetails As String = "{0, -20}{1, -20}{2, -20}{3, -20}(4, -20}{5, -20}{6, -20}"
with
Dim stddetails As String = "{0, -20}{1, -20}{2, -20}{3, -20}{4, -20}{5, -20}{6, -20}"

Acces denied to registry on windows 8 for vb.net app

I created a small app in vb.net for a friend. The problem is that on my PC (W7 64bits) it works great (registry reading / writing) but on my friends PC (W8 64bits) it doesn't work.
It it strange but at the moment he runs my app (it checks the registry on loading) it gives him a "Access to registry denied" error. I tried to run it with admin rights but it doesn't work either.
Here is my code:
Imports Microsoft.Win32
Public Class Form1
Dim planned As Date
Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.ValueChanged
End Sub
Private Sub planifier_Click(sender As Object, e As EventArgs) Handles planifier_button.Click
Dim toExecute As String = String.Format("shutdown -s -f -t {0}", 100)
Dim currentDate = System.DateTime.Now
Dim futureDate = DateTimePicker1.Value
Dim difference = futureDate - currentDate
Console.Out.WriteLine(difference)
System.Diagnostics.Process.Start("shutdown", "-s -f -t " & Math.Round(difference.TotalSeconds))
Me.planned = futureDate
saveStgFile(futureDate)
setup()
End Sub
Private Sub Shutdown_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Console.Out.WriteLine(Application.ProductName & " & " & Application.ExecutablePath)
getStgFile()
getPlanned()
setup()
Dim baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
Startup.Checked = baseKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).GetValue(Application.ProductName).Equals(Application.ExecutablePath)
End Sub
Private Sub cancel_button_Click(sender As Object, e As EventArgs) Handles cancel_button.Click
System.Diagnostics.Process.Start("shutdown", "-a")
Me.planned = Nothing
saveStgFile(Nothing)
setup()
End Sub
Sub setup()
If Me.planned.Equals(Nothing) Then
cancel_button.Enabled = False
planifier_button.Enabled = True
planifier_button.Text = "Planifier"
Else
cancel_button.Enabled = True
planifier_button.Enabled = False
planifier_button.Text = Me.planned.TimeOfDay.ToString()
End If
End Sub
Function getPlanned() As TimeSpan
Dim stg As String = getStgFile()
Dim fileContent As String = My.Computer.FileSystem.ReadAllText(stg)
Dim timespan As Date
If fileContent = "none" Then
Me.planned = Nothing
ElseIf Date.TryParse(fileContent, timespan) Then
Me.planned = timespan
End If
Return (Me.planned - System.DateTime.Now)
End Function
Function getStgFile() As String
Dim stgFile = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "AutoShutdown")
If My.Computer.FileSystem.DirectoryExists(stgFile) = False Then
FileSystem.MkDir(stgFile)
End If
stgFile = System.IO.Path.Combine(stgFile, "settings.ini")
If My.Computer.FileSystem.FileExists(stgFile) = False Then
My.Computer.FileSystem.WriteAllText(stgFile, "none", False)
End If
Return stgFile
End Function
Sub saveStgFile(planned As Date)
Dim stgFile As String = getStgFile()
Try
If (planned.Equals(Nothing)) Then
My.Computer.FileSystem.WriteAllText(stgFile, "none", False)
Else
My.Computer.FileSystem.WriteAllText(stgFile, planned.ToString(), False)
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Private Sub Startup_CheckedChanged(sender As Object, e As EventArgs) Handles Startup.CheckedChanged
Dim baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
If Startup.Checked Then
baseKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)
Console.Out.WriteLine("Add to startup")
Else
baseKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue(Application.ProductName)
Console.Out.WriteLine("Remove from startup")
End If
End Sub
End Class

Resources