|
|
The Visual Basic Index. | Main Page ~ Sign Guestbook ~ View Guestbook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Summery of tutorials Introduction to VB Lesson one Lesson Quiz Lesson two Lesson three Lesson four
VB Books + Selected Cheap UK books Fix word documents Domestic energy assessor |
Lesson 3
MsgboxesMessage boxes are used when you want to ask the user a question or display an error message(s) and advise the user. There are six types of message boxes here are their functions and what they do. Here is the listing of all the possible msgbox events
The Icons dispayed in the message box are here
The syntax for use of the message box in Mgsgbox "TEXT", VALUE, "TITLE" Source code 1 Private Sub Form_Load() MsgBox "The Device was not Found!", 48, "Header" End Sub Source code 2 Private Sub Form_Load() MsgBox "The Device was not found!", vbExclamation, "Header" End Sub You should get the picture shown below whatever source code you used. ![]() This is a basic msgbox which in this case has not been processed in any way. The following Source code displays a msgbox that ask you for specific text. For example lets make a password program out of this message box. Private Sub Form_Load()
lngBefore = Timer
End Sub
Once you copy and paste the source code you should get prompted for a password in a different type of msgbox as it includes text. From looking at this example you should be able to see how the loop function works to generate and then check the value. All of the Return Values work in the same way to return an object input.
Private Sub Form_Load()
Dim F As Integer, password As String Private Sub Form_Load()
Dim F As Integer, pass As String
End Sub
Although this is a bit obvious I think I should include it just incase I think differently to other people.
Private Sub Form_Load()
Printer.Print " The printer will print this text " End Sub
Everything that apears in position (A) will get printed by the default printer printer.print " A ". The printer enddoc is used to tell the printer the job is finished if this is not added the printer can not estimate how near it will be until it has finish and when it has finished it will think it has'nt so be sure to include this to prevent confusion.
A control array is a list of controls with the same name. Therefore, instead of using five command buttons with separate five names, you can place a command button control array on the form, and that control array holds five command buttons. The control array can have a single name, and you will distinguish the control from each other with a subscript. One of the best reasons to use control array from that first control, all the elements in the control array take on the same property values, You then can change those properties that need to be changed without having to set every property for each control individually. Control arrays have a lot in common with data arrays. A control array has one array, and you distinguish all the array's controls from each other with the zero-based subscript. ( The index property holds the controls subscript number ). All of the control elements must be the same data type. As soon as you place a control on a form that has the same name as an existing control, Visual Basic makes sure you that you want to begin a control array by issuing the warning message to show that the control is already in use. This is used as a built in safety so that you do not over right an existing control by putting it some where else on the same form. If you answer the warning box with a no button, Visual Basic uses a default control name for the placed control. Picture Not available at the moment! All event procedures that use control from a control array require a special argument value passed to them that the determines which control is being worked on. For example if your application contains a single control command button named cmdtotal the click () event begins and ends as follows Private sub cmdtotal_click() End Sub If however you create a control array named the same name as before ( cmdtotal ) it will end up like this Private sub cmdtotal_click (index as integer) End sub The procedure uses the index argument as the control index number ( the subscript ) that the user clicked, Therefore if you want to change the clicked command buttons caption property inside the cmdtotal_click () the procedures you would need are as follows Cmdtoal(index).caption = "A caption name" The index value holds the command button's index the user click to generate the event procedures so you will always respond to the proper control clicked if you use Index after the control array name. Join the mailing list to recive updates and source code Click Here
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||