Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Visual Basic for Beginners.
#1
[/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:
Code:
Label1.Text = TextBox1.Text

[Image: textboxtolabel.png]
--------------------------------------------------------------------------------------


//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


[Image: colourchange.png]

----------------------------------------------------------------------------------

// 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 soonBig Grin

//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
Reply
#2
nice thankss Smile
Reply
#3
(10-27-2009, 12:13 PM)♣Ħ€αя┼brℯ@k k!d♣ Wrote: nice thankss Smile

No problem Big Grin I have more coming soon, just need to finish writing them up Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How To make an advanced Operating System in Visual Basic 2010 ? Mohamed Samir 9 12,449 01-15-2013, 09:30 PM
Last Post: Resistance
  Source Codes For Beginners Pt.1 SouR'D 14 4,467 11-25-2012, 10:36 PM
Last Post: ƃu∀ ıʞƃu∀
  Source Codes For Beginners Pt.2 SouR'D 9 3,550 11-25-2012, 10:35 PM
Last Post: ƃu∀ ıʞƃu∀
  [Visual Basic] FTP Uploader [Tutorial] Coding Support 6 3,011 08-12-2012, 12:36 AM
Last Post: Kenneth
  Visual Studio Bill Nye The Science Guy 1 1,032 03-19-2012, 09:08 AM
Last Post: BreShiE

Forum Jump:


Users browsing this thread: 1 Guest(s)