Did you fint this helpful? Should I write more? (No ending time set)
yes
87%
[ 28 ]
no
12%
[ 4 ]
Total Votes : 32
Author
Message
Tony
Posted: 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
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
And this compleats first part of the introduction. Stay tuned for further tutorials on the use of variables, math, and comparison operations.
Posted: 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
Posted: 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. So ya, thats why I write tutorials.
But you're right, if one is to learn language, having a book is good.
Posted: 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
Posted: Fri Nov 07, 2003 10:16 am Post subject: (No subject)
sorry homer - don't know anything about winsockets
I did learn quite a bit about SQL while writing up my database project though 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