Computer Science Canada [introduction] welcome to the world of VB |
Author: | Tony [ 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 ![]() 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 ![]() 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
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
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:
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 ![]() And this compleats first part of the introduction. Stay tuned for further tutorials on the use of variables, math, and comparison operations. |
Author: | Anonymous [ Sat Jan 11, 2003 4:19 am ] |
Post 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... |
Author: | Tony [ Sat Jan 11, 2003 6:31 pm ] |
Post subject: | |
well hey, I though about publishing a book, but it doesn't work out because of printing cost. ![]() But you're right, if one is to learn language, having a book is good. |
Author: | paintball_guy [ 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 |
Author: | Homer_simpson [ Thu Nov 06, 2003 5:55 pm ] |
Post subject: | |
Awesome tutorials tony... man now u got me started with VB... keep'em coming and i'll give you bits ![]() no but seriously keep'em coming! |
Author: | Tony [ Thu Nov 06, 2003 8:22 pm ] |
Post subject: | |
what? people actually get into VB stuff? interesting ![]() well alright... I tutor Visual Basic afterschool for community hours ![]() ![]() |
Author: | Homer_simpson [ Thu Nov 06, 2003 9:41 pm ] |
Post subject: | |
so tell me... how good are u with VB? |
Author: | Tony [ Thu Nov 06, 2003 10:59 pm ] |
Post subject: | |
heh... well programming consepts are the same in all languages ![]() I feel comfortable using VB ![]() |
Author: | Homer_simpson [ Fri Nov 07, 2003 12:02 am ] |
Post 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 |
Author: | Tony [ Fri Nov 07, 2003 10:16 am ] |
Post subject: | |
sorry homer - don't know anything about winsockets ![]() I did learn quite a bit about SQL while writing up my database project though ![]() ![]() |
Author: | Homer_simpson [ Fri Nov 07, 2003 5:47 pm ] |
Post subject: | |
man it's soooo friggin great... it comes with everything yer windows could possibly do... u can even do opengl graphics on it ![]() 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... |
Author: | Homer_simpson [ Fri Nov 07, 2003 8:16 pm ] |
Post subject: | |
btw... where'd u get the mysql library for visual basic? |
Author: | Tony [ Fri Nov 07, 2003 9:36 pm ] |
Post subject: | |
Actually I used MS Access database, it's all integrated ![]() ![]() I don't remember the name of the module you have to include, but it's a standart package. |
Author: | Homer_simpson [ Fri Nov 07, 2003 11:10 pm ] |
Post subject: | |
yeah... u can include database package but u can't upload it up yer msql server man... ![]() |
Author: | Tony [ Sat Nov 08, 2003 1:12 am ] |
Post subject: | |
you might be able to host Access DB on the net ![]() |
Author: | Homer_simpson [ Sun Nov 09, 2003 12:34 am ] |
Post subject: | |
i'm 100% sure u can buy or download the mysql database access for vb off the net... |
Author: | clan_wf_mfers [ Thu Feb 19, 2004 11:20 am ] |
Post subject: | keep em comeing |
i always wanted to get into VB but the books are to confusing.. but hey keep them comeing i clearly understande you... u should be a teacher. |
Author: | Andy [ Thu Feb 19, 2004 10:04 pm ] |
Post subject: | |
if u think VB is confusing... drop compsci.... |
Author: | blackchristian888 [ Mon Jan 11, 2010 11:05 am ] |
Post subject: | Re: [introduction] welcome to the world of VB |
Great Forum!! I'm Cesar and I'm new here, just browsing for some good stuff and informative posts.. |