Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [introduction] welcome to the world of VB
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Did you fint this helpful? Should I write more?
(No ending time set)
yes
87%
 87%  [ 28 ]
no
12%
 12%  [ 4 ]
Total Votes : 32

Author Message
Tony




PostPosted: Wed Nov 20, 2002 11:53 pm   Post subject: [introduction] welcome to the world of VB

There're a lot of different programming languages out there, and a good programer knows that is it best to use different languages for different problems, as each has their own advantages and weaknesses. Turing is designed for introduction to programming, it wasn't ment for actual programming, so it is time to move on. There's Pascal, Java, C/C++, VB and now also .Net framework languages (VB.net and C#).

Here I'll try to introduce you to what I know best - Visual Basic Exclamation

So lets get started... First of all, VB might look overwhealming at first since it is soo much different from turing, but as you come to know it better, you'll realize how easy it is.

Main advantage of VB over any other language is speed. It would take a page worth of code to write a simple GUI with single button in tuirng, but in VB it is right there available at the click of your mouse. VB has a LOT of premade components, controls and APIs. Besides GUI elements as buttons and textboxes, there're also database controls and many more. It is in fact possible to make an application that connects to an access database and browses through it without any typing. With about 5 lines of code, you can modify that program to search through that database. Now thats impressive Very Happy

VB is also integrated into many applications such as all of MS office so you can write small applications INSIDE Word documents (called macros).

VB is almost as powerful as C++ and can do all but really down right ugly hardware connections. But nothing to worry, VB supports DirectX almost as good as C++ so you can make your own 3D games and applications.

Another huge difference between VB and other languages (especially turing) is that VB is event driven language. Meaning that while turing executes 1 line at a time, in order (unless you fork processes, which in fact randomly picks which of processes to execute), VB "forked" everything already and you program actions for each separate event. Such as
code:
Private Sub Button1_Click()
print "welcome to VB"
End Sub


button1 is a button that you places on the form, _Click is the even for that button... There're also others like _MouseUp, _MouseDown, _GotFocus, etc. All the different events that could happen to this particular object.

The way you write a program is that you layout the form, and you write code for different events to set up interaction between the user and the program. It is much more friendly then those ~ programs which are put/get/put/get type.

To get you started, here're a command:

msgbox("hello world") - this will make a message pop up.

Put that code inside form_load event. (Note, you don't have to type that in... you can select an object from the top left and then event from top right drop down menues. Don't worry about empty events that will be created as you pick different events from the list, all the empty events will be deleted once you refresh the code window).

form_load is the even that occurs when this form loads. A single program can have multiple forms, each with unique design and layout and they can all interact between each other.

The program you've just created should make a message "hello world" pop up at you. If you want the message to be displayed on the form as in put statment, use
code:
Print "hello world"
instead.

You should know that each object has its own "properties" such as apperance, position, the way it acts and information it holds. It is located in Properties window that by default is in bottom right. You can right click on an object and select properties to open that window.

Now to make your program a bit more interactive. Create a textbox and rename it to txt_box in the Name property. Then create a button and rename it to cmd_button. It is a good practice to rename your objects so you can find them easier later on.

Now inside the cmd_button_click event type in this code:
code:
msgbox(txt_box)


As you can see we put in the textbox object instead of the string variable. So what the program does is it reads the value from the textbox and uses that as string. Try typing different things in the textbox and clicking on the button. Notice how you didn't have to make any loops Wink

And this compleats first part of the introduction. Stay tuned for further tutorials on the use of variables, math, and comparison operations.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Guest




PostPosted: Sat Jan 11, 2003 4:19 am   Post subject: (No subject)

Tony, what do you place these tutorials for?
Forum is a place, where people ask each other questions.
If they what to learn language, they buy a book.
But I see that people look to these topics (27 View).
So may be it's better to make page with tutorials...
Tony




PostPosted: Sat Jan 11, 2003 6:31 pm   Post subject: (No subject)

well hey, I though about publishing a book, but it doesn't work out because of printing cost. Crying or Very sad So ya, thats why I write tutorials.

But you're right, if one is to learn language, having a book is good.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
paintball_guy




PostPosted: Tue Jun 10, 2003 2:01 am   Post subject: Re:

You are a saviour (if thats spelled right...w/e) thank you sooooo much... couldnt figure out VB, but now i get the hang... u rox d00d
Homer_simpson




PostPosted: Thu Nov 06, 2003 5:55 pm   Post subject: (No subject)

Awesome tutorials tony... man now u got me started with VB... keep'em coming and i'll give you bits Razz
no but seriously keep'em coming!
Tony




PostPosted: Thu Nov 06, 2003 8:22 pm   Post subject: (No subject)

what? people actually get into VB stuff? interesting Thinking

well alright... I tutor Visual Basic afterschool for community hours Laughing So perhaps I could combine two Very Happy
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Homer_simpson




PostPosted: Thu Nov 06, 2003 9:41 pm   Post subject: (No subject)

so tell me... how good are u with VB?
Tony




PostPosted: Thu Nov 06, 2003 10:59 pm   Post subject: (No subject)

heh... well programming consepts are the same in all languages Laughing

I feel comfortable using VB Very Happy
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Homer_simpson




PostPosted: Fri Nov 07, 2003 12:02 am   Post subject: (No subject)

so do i man...
but do u know anything about using winsock?
cuz i'm having trouble connectin more than 2 computers together.... =S
Tony




PostPosted: Fri Nov 07, 2003 10:16 am   Post subject: (No subject)

sorry homer - don't know anything about winsockets Confused

I did learn quite a bit about SQL while writing up my database project though Laughing VB is awesome when it comes to database interaction. You can literaly set up a database interface with 0 typing, but it's not going to be very good. A bit of SQL and it's badass Twisted Evil
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Homer_simpson




PostPosted: Fri Nov 07, 2003 5:47 pm   Post subject: (No subject)

man it's soooo friggin great... it comes with everything yer windows could possibly do... u can even do opengl graphics on it Very Happy



I'd strongly advise anyone to do VB after turing if yer not experienced programmer then move to C++ or whatever if u want more powerful programs...
Homer_simpson




PostPosted: Fri Nov 07, 2003 8:16 pm   Post subject: (No subject)

btw... where'd u get the mysql library for visual basic?
Tony




PostPosted: Fri Nov 07, 2003 9:36 pm   Post subject: (No subject)

Actually I used MS Access database, it's all integrated Laughing Heck, Access will even generate SQL statments for you Laughing

I don't remember the name of the module you have to include, but it's a standart package.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Homer_simpson




PostPosted: Fri Nov 07, 2003 11:10 pm   Post subject: (No subject)

yeah... u can include database package but u can't upload it up yer msql server man... Confused
Tony




PostPosted: Sat Nov 08, 2003 1:12 am   Post subject: (No subject)

you might be able to host Access DB on the net Confused Not sure.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: