Download presentation
Presentation is loading. Please wait.
Published byLiliana Chase Modified over 9 years ago
1
Visual Programming w/ Visual Basic How to prepare your mind to face the endless nightmare By Williem
2
To make new project In main menu, click “New Project” Choose your destination folder and remember to change your name (for the sake of originality, you’ll see later)
3
VS Topography Left Side : Toolbox Bottom-Right Side : Properties of selected object Top-Right Side : Solution and Project Mapping/Explorer Upside Menu Bar Form to create your interface The holy green triangle to debug and start your program
4
Gizmos Button Checkbox Label Combobox RadioButton Textbox GroupBox Timer IMPORTANT! To change every information regarding to specific objects, go to the Properties. It is essential
5
How to create the interface VB consentrates on creating a user interface and manipulating the objects so we can do something better or even create and application E.g. Create an application that says “Hello World” when a button is clicked
6
How to: 1.Create a new project 2.From the toolbox, drag the “Button” tool to the Form 3.To change the button’s text, go to Properties and change the “Text” infobox 4.To manipulate the code (sorry to say such holy word), double-click the button in the form*. 5.In the code, under the Private Sub blablabla, type “MsgBox(“Hello World”)” 6.Click the holy green triangle P.S. : *This applies to every object in later use, just keep in mind
7
Variables Almost same as C/C++, variable defining is essential in VB To define variable use “Dim” keyword Visual Basic is not case sensitive, so A and a are just the same. Be careful. To comment your program use the apostrophe ( ‘ )
8
MsgBox MsgBox (not MonoSodium Glutamate) is essential and can be manipulated MsgBox([Contents], [Type], [Box Text]) If you want to concatenate string, use “+” or it will be much professional to use “&” because it does for string and numerical * Types of the textbox determine the style, can be exclamation, yes or no, ok or cancel, ok, etc. MsgBoxStyle.Information MsgBoxStyle.Exclamation And many other stuffs you can explore *p.s. : because you will encounter some program with direct addition in the box
9
Textbox To take the value of text input, use “[TextBox_Name].Text” E.g. Dim myInt As Integer myInt = Textbox1.Text Converting is essential in taking input value. The only reason is every input you do in the textbox is taken as String value. To convert to Integer: myInt = Cint(Textbox1.Text), etc. Double = CDbl String = CStr Single = CSng A question: What if the input is 12A?
10
So easy… Just use “IsNumeric()” function. IsNumeric([Input]) This function returns Boolean value (True / False) What does “IsNumeric(Textbox1.Text) = False” ? Almost all programs in Visual Programming use this function. KEEP IN MIND
11
The Math Logic or Boolean Algebra Remember “||” or “&&” ? In VB, we use “And” or “Or” || is Or && is And <> is Not Same As (or ‘!=‘ in C/C++) ! is Not == and = is different and it is self-explanatory.
12
RadioButton To make it checked by default, go to Properties->Checked->True To use it in code, [RadioButton_Name.Checked] In default, it is considered true. Example: Male.Checked = False, what does it means? And it can be combined with logic And / Or to achieve some purposes.
13
Conditional (If-Else-Elseif) and (Select- Case) Like other languages, the If-else-elseif in VB is just the same, but remember, you have to be able to separate some if Always remember, after If – Then, Elseif – Then, Else (no Then) and End If. *usually auto-typed by VB, but keep your eyes on them unless you want to shout like sh*t when error happens in debugging because of no “End If” or even “Then” Select is like switch Select Input Case 0 Condition…. …(continue) End Select
14
Loops (While, Do While, For) While and Do While is like in C/C++ except for While, it has End While Do … Loop While/Until. Or Do While (Condition) … Loop. It is self-explanatory or not clear enough? For … To … (Step -a) Next Step is used to determine the difference in every loop, can be negative or positive
15
Bonus Sneak-Peek (Array) Usually used to manipulate string. To take string length just use myStr.Length as in C/C++ Dim myStr As String myStr = Textbox1.Text ‘Assume input is Hello MsgBox(“The character is” & myStr(2)) …. What is the result?
16
Challenge 101 Create a program that counts temperature from: Fahrenheit to Celcius and vice versa Celcius to Reamur and vice versa Reamur to Fahrenheit and vice versa All to Kelvin and vice versa And Show the conversion result Use one textbox, one button and 8 radiobutton Create a program that reads String input from textbox and Reverse it manually with loop by clicking a button (any loop will do), then show the result! Use one-dimensional array! (there are two ways to do it )
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.