vb6 basics

18
1

Upload: nisankalk

Post on 11-Jan-2016

294 views

Category:

Documents


3 download

DESCRIPTION

Basic startup for VB6

TRANSCRIPT

Page 1: VB6 Basics

1

Page 2: VB6 Basics

2

MICROSOFT VISUAL BASIC 6.0

Basic Components

Key Events

Conditional Statements (If then ..Else)

Variables

Message Box/Input Box

Procedures & FunctionsASCII

Control Statements(Loops)

Page 3: VB6 Basics

3

Basic Components

Label

Frame

Checkbox

Text Box

Command Button

Option Button

Page 4: VB6 Basics

4

Command Button

Private Sub CMDcal_Click()<statement 1><statement 2>

End Sub

Page 5: VB6 Basics

5

Text BoxLabel

Page 6: VB6 Basics

6

Conditional Statements

IF CONDITION THENSTATEMENT 1

ELSESTATEMENT 2

END IF

Page 7: VB6 Basics

7

Conditional Statements

IF CONDITION 1 THENstatement 1

ELSE IF CONDITION 2 THENstatement 2

ELSE IF CONDITION 3 THENstatement 3

End IF

Page 8: VB6 Basics

8

KeyPress > SetFocus Event

Private Sub TXTN1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 ThenTXTN2.SetFocusEnd If

Page 9: VB6 Basics

9

Setting Variables

Dim X, Y, Z As Variant

PUBLIC, LOCAL, DIM, PRIVATE

Any Number of Variables for the requirement

Variant, Integer, Byte,String

Page 10: VB6 Basics

10

Setting Variables

It is not required to declare all the variables in theGENRAL DECRALARION.

Declare variables as the requirement

Page 11: VB6 Basics

11

Setting Variables

It is not required to declare all the variables in theGENRAL DECRALARION.

Declare variables as the requirement

Page 12: VB6 Basics

12

Message Boxes

Private Sub CMDplus_Click()

MsgBox "Testing Message Boxes", vbCritical + vbExclamation, "Warning"

End Sub

Page 13: VB6 Basics

13

Message Boxes > Capturing Return Value

Private Sub CMDplus_Click()Dim x As Stringx = MsgBox("Are you sure want to exit ? ", vbYesNo

+ vbCritical, "Confirmation") If x = vbYes Then End Else CMDplus.SetFocus

End If

Page 14: VB6 Basics

14

Message Boxes > Result into 2 Lines

Private Sub CMDplus_Click()MsgBox "Display Line 1" & vbCrLf & "Display

Line 2“,vbCritical + vbExclamation,"Warning"

End Sub

Page 15: VB6 Basics

15

Option Button

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

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

End Sub

Page 16: VB6 Basics

16

Check Boxes

Private Sub CheckMo_Click()If CheckMo.Value = 1 ThenLabel1.Caption = Val(Label1.Caption) + 10000ElseLabel1.Caption = Val(Label1.Caption) - 10000End IfEnd Sub

Private Sub CheckKey_Click()If CheckKey.Value = 1 ThenLabel1.Caption = Val(Label1.Caption) + 1500ElseLabel1.Caption = Val(Label1.Caption) - 1500End IfEnd Sub

Private Sub CheckSys_Click()If CheckSys.Value = 1 ThenLabel1.Caption = Val(Label1.Caption) + 25000ElseLabel1.Caption = Val(Label1.Caption) - 25000End IfEnd Sub

Page 17: VB6 Basics

17

Check Boxes

Page 18: VB6 Basics

18

Control Statements - LoopsFor LoopFor <exp1> to <exp2>

part A

next

exampleFor i=1 to 10Print “HNDE”

next

For i=1 to 10 step 2Print INext

1 3 5 7 9