Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Basic. The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()

Similar presentations


Presentation on theme: "Visual Basic. The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()"— Presentation transcript:

1 Visual Basic

2 The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()

3 Msgbox PromptText Icon Buttons Dialog title

4 Msgbox -Parameters The message box function takes 3 main parameters: Msgbox (Prompt Text, Buttons+Icon, DialogTitle) [ Prompt is a string which contains the message. ] Button Constant vbOKOnly vbOkCancel vbYesNo vbYesNoCancel vbAbortRetryIgnore vbRetryCancel Icon ConstantIcon vbQuestion vbInformation vbExclamation vbCritical

5 Msgbox -Example Dim Ans As String Ans = Msgbox("Are you sure?", vbYesNo+vbExclamation,- "Front Page Editor") OR Ans = MessageBox.Show("Are you sure", "FrontPage Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)

6 InputBox InputBox: predefined dialog box that includes a prompt, a textbox, and an OK and Cancel buttons. It is used to get information from the user. Prompt: question or instruction for the user. Title: for InputBoxes, the text that appears in the blue bar at the top

7 Input Box PromptText DefaultText DialogTitle

8 Parameters: The input box function takes three main parameters: InputBox ( PromptText, DialogTitle, DefaultText) Example: Dim DocName As String DocName = InputBox ("Please enter the documents title", _ "Enter Title", "Document 1") Input Box

9 Specific Example Dim strUserName As String strUserName = InputBox(“What is your name?”, “Request Name”) If the user enters no text, or presses the cancel button, then the InputBox function will return the value Nothing. You can check for this in your code: If strUserName = Nothing Then MessageBox.show(“Cancelled”) End Ifz If the user has entered some text into the textbox and pressed the OK button, then the text they entered is now saved in the variable strUserName. Input Box

10 Space Function Used to add spaces to your string. Just call it and send to it the number of spaces you want. Example: Dim Str1 as String = “Hello” & Space(5) & “, You just add 5 spaces” MsgBox(Str1)

11 Progress bar Progress bars are used to display the progress of your application or background tasks. There are three members of the ProgressBar control you should know about: the Maximum, the Minimum, and the Value properties.

12

13

14

15 Status Bar Status Bars are used to display status messages at the bottom of the form. They are generally used to provide additional information, such as page numbers, display a message, etc.

16

17

18

19 Random Numbers -Declaration Dim randomNumber As Random = New Random Variable nameData typeInitialization

20 Random Numbers -Methods  Next()  Non-negative random integer  NextDouble()  A double between 0.0 and 1.0  Next(IntegerValue)  A positive integer < IntegerValue  Next(IntValue1,IntValue2)  IntValue1 <= an integer < IntValue2

21 Random Numbers -Example Dim randomNumber As Random randomNumber = New Random Dim number As Integer number = randomNumber.Next(10, 20) MsgBox(number)

22 Design view Code view b1 Private Sub LotsOfButtons(ByVal sender As _ System.Object,ByVal e As System.EventArgs) _ Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click label1.text = sender.text & “ is clicked” End Sub b2 b3 b4 Name : label1 3. Multiple Events by Single Handler

23 Design view code view b1 b2 b3 b4 b3 is clicked Name : label1 The sender argument provides information about the object that raises the event 3. Multiple Events by Single Handler Private Sub LotsOfButtons(ByVal sender As _ System.Object,ByVal e As System.EventArgs) _ Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click label1.text = sender.text & “ is clicked” End Sub

24 Why do you need to know this ? In sheet 3, you can handle clicking all the 26 letters by single event handler. Each time just get the sender.text to check the letter chosen !!!!


Download ppt "Visual Basic. The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()"

Similar presentations


Ads by Google