vb6 basics

Download VB6 Basics

Post on 11-Jan-2016

229 views

Category:

Documents

1 download

Embed Size (px)

DESCRIPTION

Basic startup for VB6

TRANSCRIPT

Slide 1

11MICROSOFT VISUAL BASIC 6.0Basic ComponentsKey EventsConditional Statements (If then ..Else)VariablesMessage Box/Input BoxProcedures & FunctionsASCIIControl Statements(Loops)

2Basic Components

LabelFrameCheckboxText BoxCommand ButtonOption Button3Command ButtonPrivate Sub CMDcal_Click()

End Sub

4Text BoxLabel

5Conditional Statementsif CONDITION thenstatement 1elsestatement 2end if6Conditional StatementsIF CONDITION 1 THENstatement 1ELSE IF CONDITION 2 THENstatement 2 ELSE IF CONDITION 3 THENstatement 3End IF7KeyPress > SetFocus EventPrivate Sub TXTN1_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTXTN2.SetFocusEnd If8Setting VariablesDim X, Y, Z As VariantPUBLIC, LOCAL, DIM, PRIVATEAny Number of Variables for the requirementVariant, Integer, Byte,String9Setting VariablesIt is not required to declare all the variables in theGENRAL DECRALARION.

Declare variables as the requirement

10Setting VariablesIt is not required to declare all the variables in theGENRAL DECRALARION.

Declare variables as the requirement

11Message BoxesPrivate Sub CMDplus_Click()MsgBox "Testing Message Boxes", vbCritical + vbExclamation, "Warning"End Sub

12Message Boxes > Capturing Return ValuePrivate Sub CMDplus_Click()Dim x As Stringx = MsgBox("Are you sure want to exit ? ", vbYesNo + vbCritical, "Confirmation") If x = vbYes Then End Else CMDplus.SetFocusEnd If

13Message Boxes > Result into 2 LinesPrivate Sub CMDplus_Click()MsgBox "Display Line 1" & vbCrLf & "Display Line 2,vbCritical + vbExclamation,"Warning"End Sub

14Option Button

Private Sub OptionF_Click()Label1.Caption = "Female"End Sub

Private Sub OptionM_Click()Label1.Caption = "Male"End Sub

15Check BoxesPrivate Sub CheckMo_Click()If CheckMo.Value = 1 ThenLabel1.Caption = Val(Label1.Caption) + 10000ElseLabel1.Caption = Val(Label1.Caption) - 10000End IfEnd SubPrivate Sub CheckKey_Click()If CheckKey.Value = 1 ThenLabel1.Caption = Val(Label1.Caption) + 1500ElseLabel1.Caption = Val(Label1.Caption) - 1500End IfEnd SubPrivate Sub CheckSys_Click()If CheckSys.Value = 1 ThenLabel1.Caption = Val(Label1.Caption) + 25000ElseLabel1.Caption = Val(Label1.Caption) - 25000End IfEnd Sub

16Check Boxes

17Control Statements - LoopsFor LoopFor to part AnextexampleFor i=1 to 10Print HNDEnextFor i=1 to 10 step 2Print INext

1 3 5 7 9

18