Page 1 of 2

[TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Fri Sep 11, 2009 10:53 pm
by HWJgavin
Important
Well,are you interested in taking up Visual Basic?Not just because of hacks,it must be because of pure interest that gives you the heart to learn visual basics!
______________________________

Firstly,
Get Visual Basic - http://www.microsoft.com/express/download/

Now back on the tutorial,
I know the first sight is,oh god why the hell am i learning this,its so complicating,but fear not it is actually very easy.
For the first lesson,i will teach you how to do a easy caculator with VB that i learned from a website and a book last time when i learned VB.
______________________________

Here we go!
_________
To start creating your first application, you need to click on file and select new project.
________________________________________
The dialog box will then offer you a few choices,because we will be learning to create windows application,Select Windows Form Application.
________________________________________
Great!you already created your first program with VB :P,Well lets continue,Near the bottom of the dialog,you can change the project name,WindowsApplication1 to some other name you like,Eg.ImlearningVB.After you have renamed the project, click OK to proceed then a window will popup.
________________________________________
Well this step is complicated but you should be able to do it,drag one common button into the form and change its default name to calculate.
Next, click on the calculate button and key in the following code at the source code window as shown below.
________________________________________
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num1, num2, sum As Single
num1 = 100
num2 = 200
sum = num1 + num2
MsgBox(" Answer of " & num1 & " and " & num2 & " is " & sum)

End Sub
________________________________________
^(Do not mess up at this part!)
For your first program,you insert two textboxes , three labels and one button. The two textboxes are for the users to enter two numbers, one label is to display the multiplication operator and the other label is to display the equal sign. The last label is to display the answer.
________________________________________
The code for the caculation of multiply is

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim num1, num2, product As Single
num1 = TextBox1.Text
num2 = TextBox2.Text
product = num1 * num2
Label3.Text = product

End Sub
________________________________________

End of Lesson 1
-----------
Do checkback for updates!

Credits:
vbtutor.
some videos on vb.

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Fri Sep 11, 2009 10:57 pm
by Boredness
Virtual Basic is good for beginner programmers

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Fri Sep 11, 2009 11:37 pm
by HWJgavin
Will add in pictures if i have time on the next lesson.

EDIT:Btw boredness u spelled visual basic wrong :lol:

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Fri Sep 11, 2009 11:50 pm
by Ladylove
My time to learn. :lol:

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Sat Sep 12, 2009 12:37 am
by HWJgavin
Next lesson will probably be Variables or maybe teaching you to code another program and slowly moving on to hacking,creating pranks etc.

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Sat Sep 12, 2009 12:47 am
by Ladylove
This will help much. 1 by 1 learning session. (:

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Sat Sep 12, 2009 11:55 am
by Slayer369
nice tut, it may help beginner who wanna learn programing

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Sat Sep 12, 2009 12:15 pm
by HWJgavin
Yeah,VB is actually good IMO.
Anway,i will post the next lesson tmr or today.

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Mon Sep 14, 2009 6:39 pm
by wizme
eh i think its abit confusing, from what i see from your code, you only used 1 label , but u told use to use 3, so what i do with the other 2. i think we use the label to show the + sign and the = sign.

also how do i error check the test bos field, like if we type in alpha, an error will occur or how i can i only enable the input of numbers? thx

and also how to i build the exe file out

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

I found out here already.
Heres my code for adding of 2 numbers with some error checking.

Code: Select all

Public Class Form1

    Private Function myFunc1(ByVal numb1, ByVal numb2)
        Dim result As Single
        result = numb1 + numb2
        Return result
    End Function

    Private Sub calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculate.Click
        Dim num1, num2 As Single
        If TextBox1.Text = "" Then
            MsgBox("Please enter something in the 1st box!")
        ElseIf TextBox2.Text = "" Then
            MsgBox("Please enter something in the 2nd box!.")
        ElseIf Not IsNumeric(TextBox1.Text) Then
            MsgBox("Please enter numbers only.")
            TextBox1.Text = ""
        ElseIf Not IsNumeric(TextBox2.Text) Then
            MsgBox("Please enter numbers only.")
            TextBox2.Text = ""
        Else
            num1 = TextBox1.Text
            num2 = TextBox2.Text
            Label3.Text = myFunc1(num1, num2)

        End If
    End Sub
End Class
This is my SS, 2 text box and 3 label.
Image
ops ps i spell wrongly lol

Re: [TUT]Visual Basic .NET Tutorial [Noob friendly]

Posted: Mon Sep 14, 2009 8:42 pm
by HWJgavin
Haha,mistaken a lil,will edit when i've time,really busy for EOYS,sorry bout that :]