[/align]All these little snippets are to get newbies going. Some can be done differently which are more complicated but of course benefit in the future but im showing the easy ones.
//Get the value of a textbox to display in a label on click of a button. (Beginner)
Place a button, textbox and label on the windows form in visual basic express or visual studio (what i use)
Next, double click on the button you have just placed and copy/paste this code. For this to work do not change the textbox, or labels name. If you do edit the code to match the names.
simple as this:
--------------------------------------------------------------------------------------
//Enter a color into a textbox, to change the forms background. (Beginner)
Place a textbox and a button onto your windows form.
Next, double click your button to go into code mode and cop/paste this code in
-- To add more colours, simply after "Me.BackColor = Color.Pink" and before "End IF" add "ElseIf TextBox1.Text = "blue" Then
Me.BackColor = Color.Blue (just change color values)
----------------------------------------------------------------------------------
// Simple codes to remember.....
Me.Close() - closes the form you are working in. because visual basic cannot referance itself, for example Form1.Close() it has to use Me.
----------------------------------------------------------------------------------
Me.Hide() - hides the form, while not exiting the aplication. Best to use it like this:
----------------------------------------------------------------------------------
Form2.Show() - grabs form2 and displays it.
----------------------------------------------------------------------------------
Simple If Statement
----------------------------------------------------------------------------------
More beginner ones coming soon
//Heres a more harder one:: How to save a users setting choice.
Sometimes this baffles people on how to do this, well it's simple as eating cheesecake pie :L
-----read on to the next reply of screenshots and info on how to do it
All code is mine and is not copied from elseware. Not like its difficult, its basic. get it visual basic.... lol, easly amused. just i can sense some guy will say something
//Get the value of a textbox to display in a label on click of a button. (Beginner)
Place a button, textbox and label on the windows form in visual basic express or visual studio (what i use)
Next, double click on the button you have just placed and copy/paste this code. For this to work do not change the textbox, or labels name. If you do edit the code to match the names.
simple as this:
Code:
Label1.Text = TextBox1.Text
--------------------------------------------------------------------------------------
//Enter a color into a textbox, to change the forms background. (Beginner)
Place a textbox and a button onto your windows form.
Next, double click your button to go into code mode and cop/paste this code in
-- To add more colours, simply after "Me.BackColor = Color.Pink" and before "End IF" add "ElseIf TextBox1.Text = "blue" Then
Me.BackColor = Color.Blue (just change color values)
Code:
If TextBox1.Text = "red" Then
Me.BackColor = Color.Red
ElseIf TextBox1.Text = "blue" Then
Me.BackColor = Color.Blue
ElseIf TextBox1.Text = "pink" Then
Me.BackColor = Color.Pink
End If
----------------------------------------------------------------------------------
// Simple codes to remember.....
Me.Close() - closes the form you are working in. because visual basic cannot referance itself, for example Form1.Close() it has to use Me.
----------------------------------------------------------------------------------
Me.Hide() - hides the form, while not exiting the aplication. Best to use it like this:
Code:
Form2.Show()
Me.hide()
----------------------------------------------------------------------------------
Form2.Show() - grabs form2 and displays it.
----------------------------------------------------------------------------------
Simple If Statement
Code:
if textbox1.text = "sauce" Then
Form2.Show()
else Me.close()
EndIf
----------------------------------------------------------------------------------
More beginner ones coming soon
//Heres a more harder one:: How to save a users setting choice.
Sometimes this baffles people on how to do this, well it's simple as eating cheesecake pie :L
-----read on to the next reply of screenshots and info on how to do it
All code is mine and is not copied from elseware. Not like its difficult, its basic. get it visual basic.... lol, easly amused. just i can sense some guy will say something