I am new for programming and trying to learn VB.net through youtube tutorials. so I tried to create separate forms for a "login" and "create new account". The login seems to work fine. However, the create account becomes difficult for me to successfully code it. The main issue I have is with the "Insert" code. I created a "createnewaccount" form and connected a database to it. Then I write a code under "btnsave" so that when people create new account it will be saved to the database. This is where I keep getting issues. where it says "UsersPasswordsTableAdapter1.Insert" it underlines it all the time and the program wouldn't work. Here are my codes. Any help would be helpful.
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class CreateNewAccount
Private Sub CreateNewAccount_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.UsersPasswordsTableAdapter1.Fill(Me.UsersPasswordsDataSet1.UsersPasswords)
End Sub
Private Sub btnSaveNewAccount_Click(sender As Object, e As EventArgs) Handles btnSaveNewAccount.Click
LoginPage.UsersPasswordsTableAdapter1.Insert(Me.TextBox1.Text, Me.TextBox2.Text, Me.TextBox3.Text)
LoginPage.UsersPasswordsTableAdapter1.Fill(LoginPage.UsersPasswordsDataSet1.UsersPasswords)
MsgBox("Your Account has been saved successfully", MsgBoxStyle.Information)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub btnBacktoLogin_Click(sender As Object, e As EventArgs) Handles btnBacktoLogin.Click
Me.Hide()
LoginPage.Show()
End Sub
End Class
Related
Hello to stackoveflow community members.!
I am reading threads from stackoverflow from past 6 months and which was really helpful for me. I never get stuck to anything where i need to write my own question here.
Currently i am working on visual studio 2015 with window based .net application.
I am having multiple forms in my application. I am loading a form into another form through panel control.
Say i have a form1 which is main form and form2 which i have opened main form using panel control.
When i am opening my form1 as startup form the data transfer is taking place. But when i am using another form say form3 for login page as startup the data transfer is not working between form1 and form2.
Could some please help.!!
Please find example code as below.
enter image description here
Number of Forms - 3,
Form3 as Login Form,
Form1 as Main Form,
Form2 as Entry Form,
Code for Form3-==========
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim form1 As New Form1
form1.Show()
Me.Hide()
End Sub
Code for Form1-===========
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RichTextBox1.Text = "Hello"
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim f As Form
f = Form2
f.TopLevel = False
f.WindowState = FormWindowState.Normal
f.FormBorderStyle = FormBorderStyle.None
Me.Panel1.Controls.Add(f)
f.Dock = DockStyle.Fill
f.Show()
End Sub
Code for Form2-=========
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form1.RichTextBox1.Text = Me.TextBox1.Text
End Sub
As suggested by 'Preciousbetine', i have removed new instance for form1. Application is working as desired.
Thank you so Much!!!
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form1.Show()
Me.Hide()
End Sub
I am trying to incorporate VLC into my VB program. I have included the COM tool VLCActiveXPlugin_V2. In the ‘openfiledialog1’ properties the ‘InitialDirectory’ is set to ‘E:\Movies\’,which is where my .mp4 movies are stored. When I run the program and press btnLoad the openfiledialog1 opens E:\Movies but it said ‘No items match your Search’! The code is adapted from a .net tutorial and works fine for him. I am ‘ASSUMING’ it was written with an older version of VB and/or .NET.
Anybody have any ideas?
This is just a test trying to get the playback to work, the end product will be that a user can create a DataGridView listing of the available movies, pick one of the movies and ‘hopefully’ the program will play that movie.
Code:
Public Class Form1
Private Sub btnLoad_Click(sender As Object, e As EventArgs) Handles
btnLoad.Click
OpenFileDialog1.Filter = " (*.mp4) | .mp4 "
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
AxVLCPlugin21.playlist.add(OpenFileDialog1.FileName)
End If
End Sub
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles
btnStart.Click
AxVLCPlugin21.playlist.play()
End Sub
Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles
btnStop.Click
AxVLCPlugin21.playlist.stop()
End Sub
Private Sub btnPause_Click(sender As Object, e As EventArgs) Handles
btnPause.Click
AxVLCPlugin21.playlist.togglePause()
End Sub
End Class
I'm getting an error (BC30451), with my code, but I just can't seem to work out what it is. I've been working on this for a while now, and it's really annoying how I can't compile it.
Code:
Imports System.Net
Imports System.Net.NetworkInformation
Public Class Login1
Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
Me.Close()
End Sub
Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If My.Computer.Network.Ping("www.Google.com") Then
MsgBox("Your Computer is currently connected to our database.", "Success!")
Else
MsgBox("Your Computer is currently not connected to our servers.", "Fatal Error")
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox8.Text = My.Settings.username AndAlso TextBox9.Text = My.Settings.password Then
MsgBox("You have successfully been logged in!")
Close()
Main.Show()
Else
MsgBox("That username or password is incorrect, please try again.")
Me.Close()
Form1.Show()
End If
End Sub
End Class
In the Main.Show(), it's saying that Main is not declared, even though it's a valid project within Visual Studio I'm using.
Also, for some reason, next to 'Main.vb', instead of the normal software box you should get, it just has a blue logo saying 'VB'. Here is a screenshot:
I searched over the Stackoverflow and Google about solution for my problem but no way! so it's the time to ask my own question.
I'm making a big project using C# and VB.net (not our topic -_-)
I opened this question to ask about VB.net problem
I'm trying to load a lot of forms but in the same time, hide the previous form!
Firstly, look here on Form1:
Private Sub Timer4_Tick(sender As Object, e As EventArgs) Handles Timer4.Tick
If Label1.Text = "Setting profile.dat=Roblox.AuthAccess ..." Then
Form2.Show()
Me.Hide()
End If
End Sub
This is a timer, which detect if Label1's Text is "Setting profile.dat=Roblox.AuthAccess ..." it must show Form2 and then close Form1 (THIS IS WORKING PERFECTLY) :-)
Form2:
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If WebBrowser1.Url.ToString().Contains("home") Then
Me.Hide()
Form3.Show()
End If
End Sub
This will detect if "WebBrowser1"'s URL does contain "home" then it will hide Form2 and show Form3 (AND HERE THE PROBLEM STARTED!!!)
Problem is: It shows Form3 then after 2 seconds, Form2 come back again (now both are opened once) and they're opening and closing forever (I close them by going to Task Manager and ending "vshost32.exe")
Form3:
Public Class Form3
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Form2.Close()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Form4.Show()
End Sub
End Class
Actually, stopping timers is still not a stable solution and disabling them are more better.
Just replace Timer4.Stop() with Timer4.Enabled = False .
Thank you very much #jmcilhinney :)
I never thought about stopping every "Timer" after it's job had finished!
Just replaced Timer4_Tick with:
Private Sub Timer4_Tick(sender As Object, e As EventArgs) Handles Timer4.Tick
If Label1.Text = "Setting profile.dat=Roblox.AuthAccess ..." Then
Me.Hide()
Form2.Show()
Timer4.Stop()
End If
End Sub
So at last, I fixed that by adding Timer4.Stop() .
Let me just start this with what the program is trying to accomplish before I start with my problem. I'm working on a program that checks every 5 to 10 (not implemented yet) seconds to see if you VPN has dropped the way I'm doing this having the user type in there IP before they start the VPN and then they start the VPN and it checks to see if it changes. My problem is that when I compare the two strings even if they are the same the program stays they are different.
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LbIP.Text = GetIP()
End Sub
Function GetIP() As String
Dim IP As New WebClient
Return IP.DownloadString("http://icanhazip.com/")
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If GetIP() = TextBox1.Text Then
Label1.Text = "VPN DROPPED"
Else
Label1.Text = "Your Good"
End If
End Sub
End Class
DownloadString will return ip address with \n at the end of the string. you need to remove that and compare.
sample work around
If GetIP().Replace("\n","") = TextBox1.Text Then
Label1.Text = "VPN DROPPED"
Else
Label1.Text = "Your Good"
End If