Visual Programming
Visual Programming
Visual programming
In computing, a visual programming language is any programming language that
lets users create programs by manipulating program elements graphically rather than by
specifying them textually.
2.
Pointer
PictureBox
TextBox
Frame
CommandButton
CheckBox
OptionButton
ListBox
ComboBox
HScrollBar and
VScrollBar
Timer
DriveListBox
DirListBox
FileListBox
Shape
Line
Image
Data
OLE
Label
3. A property is a value or characteristic held by a Visual Basic object, such as
Caption or Fore Color. Properties can be set at design time by using
the Properties window or at run time by using statements in the program code.
4. A Determinate Loop is one for which the number of times the loop will be executed
is known in advance. The number of executions of the loop is hard-coded into the
program. For example, we may be counting a number of objects whose maximum
number cannot exceed 100.
5. If the condition evaluates to true, then the block of code inside the If statement will
be executed. If condition evaluates to false, then the first set of code after the end of
the If statement (after the closing End If) will be executed.
6. You can use the DateDiff function to determine how many specified time intervals
exist between two dates. For example, you might use DateDiff to calculate the
number of days between two dates, or the number of weeks between today and the
end of the year.
7. Structuring your code with procedures gives you the
following benefits: Procedures allow you to break your programs into discrete
logical units. You can debug separate units more easily than you can debug an entire
program without procedures.
8. In Visual Basic, a control array is a group of related controls in a Visual
Basic form that share the same event handlers. ... One application of control
arrays is to hold menu items, as the shared event handler can be used for code
common to all of the menu items in the control array.
9. The programming model of Visual Basic is event driven: As the user interacts with
the controls on your form, some code is executed in response to user actions. The
user's actions cause events, and each control recognizes its own set of events and
handles them through subroutines, which are called event handlers.
10. VBA InputBox is used to prompt the user to enter the values. This message box is
used to displaying a message and waits for the user action performed by pressing
the button. A text can be return in the text box by using the InputBox function if the
user clicks on the OK or Enter button.
Dim It is useful to declare and allocate the storage space for one or more variables.
[Variable Name] It’s the name of the variable to hold the values in our application.
As The As clause in the declaration statement allows you to define the data type.
[Data Type] t’s a type of data the variable can hold such as integer, string, decimal, etc.
Object 4 bytes on a 32-bit platform, Any type can be stored in a variable of type Object
8 bytes on a 64-bit platform
User- Depends on Platform Each member of the structure has a range determined by its data
Defined type and independent of the ranges of the other members
Now, we will see how to use the Data Types in our visual basic applications with examples.
22. Events are basically a user action like key press, clicks, mouse movements, etc.,
or some occurrence like system generated notifications. Applications need to
respond to events when they occur.
Clicking on a button, or entering some text in a text box, or clicking on a menu item,
all are examples of events. An event is an action that calls a function or may cause
another event. Event handlers are functions that tell how to respond to an event.
VB.Net is an event-driven language. There are mainly two types of events −
Mouse events
Keyboard events
using ODBC
This lesson demonstrates how to use ODBC to connect to a database. Here we
have accessed MS Access Database and have fetched results from it. We have
created this example using LiveCode, MS Access 2003 and Windows XP, but you
can use ODBC to connect to any database that supports it, from within LiveCode.
You can download the associated sample stack and database for this lesson below
from this url: https://tinyurl.com/ya5he5y3
ODBC_Lesson.zip
Click File->New, this will open a Tab in the right side of the Application which will ask
you to select what type of DataBase you are creating. Click Blank Database option.
This will create a blank Database, which we have named livecodeTest.
Creating a table in MS Access
Zoom: Creating a table in MS Access
Click "Create Table in Design View" , this will open up the table design. Add two
fields labeled Name and Company to the table and save it.
Double click the table "test", this will open the blank table. Fill in some data and then
save the table and database.
Step 1: Goto Control panel -> Administrative Tools -> Data Sources(ODBC).
Step 2: Add new Data Source
Click the ADD button. This will popup a window asking for the correct driver, Select
Microsoft Access Driver (*.mdb) and click finish
on mouseUp
local tDatabaseID
--This will open up connection for the MS Access Database using a ODBC
connection
put revOpenDatabase("ODBC", "runrev", "livecodeTest", "testUser", "123456" )
into tDatabaseID
if tDatabaseID is null then
answer "Not connected"
else
answer "connected"
--This statemenr will select all the data from the table Test
put "SELECT * FROM test" into tQuery
--This will query the Database Table using the statement in tQuery
put revDataFromQuery(tab, cr, tDatabaseID, tQuery) into tData
--This will display all the data from the Database
put tData into field 1
--This closes the Database connection
revCloseDatabase tDatabaseID
end if
end mouseUp
A message box is a special dialog box used to display a piece of information to the user. As opposed
to a regular form, the user cannot type anything in the dialog box. To support message boxes, the
Visual Basic language provides a function named MsgBox. To support message boxes, the .NET
Framework provides a class named.
To display a simple message box, you can use the MsgBox() function with the following formula:
MsgBox(Message)
If the message is made of different sections, you can concatenate them using the & operator. You can also
first declare a String variable, initialize it, and pass it to the function.
To create a message box using the .NET Framework, you can call the Show() method of the MessageBox
MessageBox.Show(Message)
As done for the MsgBox() function, pass a string to the method. Here is an example:
In our lessons, we will mostly use the MsgBox() function, not because it is better than the MessageBox
class. It is simply a preference; but it is also because these lessons are for Microsoft Visual Basic, so we
Show Method:
This method is used to display the form on top of all other windows even if it is loaded or not loaded into the
memory.
Syntax:
FormName.Show
or
FormName.Show(1,)
In the above syntax, the Show method can also have argument values 0 or 1 for Modeless or Modal forms.
By default this methods modeless or normal forms, but the modal forms more interactive.
until a given condition is satisfied. A For loop is useful in such a case when we know how
many times a block of code has to be executed. In VB.NET, the For loop is also known as For
Next Loop.
Syntax
For variable_name As [ DataType ] = start To end [ Step step ]
[ Statements to be executed ]
Next
the variable determines when to exit from the For-Next loop, and the value should only be
a numeric.
and final values of the variable_name. These parameters are helpful while the execution begins,
the initial value of the variable is set by the start. Before the completion of each repetition, the
variable's current value is compared with the end value. And if the value of the variable is less
than the end value, the execution continues until the variable's current value is greater than the
The common dialog controls are invisible at runtime, and they’re not placed on your
forms, because they’re implemented as modal dialog boxes and they’re displayed as
needed. You simply add them to the project by double-clicking their icons in the
Toolbox; a new icon appears in the components tray of the form, just below the Form
Designer. The common dialog controls in the Toolbox are the following:
OpenFileDialog – Lets users select a file to open. It also allows the selection of
multiple files for applications that must process many files at once.
SaveFileDialog – Lets users select or specify the path of a file in which the current
ColorDialog – Lets users select a color from a list of predefined colors or specify
custom colors. FontDialog Lets users select a typeface and style to be applied to the current
text selection. The Font dialog box has an Apply button, which you can intercept from within
your code and use to apply the currently selected font to the text without closing the dialog
box.
Figure 4.10 – The Open and Font common dialog boxes
There are three more common dialog controls: the PrintDialog, PrintPreviewDialog,
and PageSetupDialog controls. These controls are discussed in detail in Chapter,
“Printing with Visual Basic 2008,” in the context of VB’s printing capabilities.