All the Notes in one Place. Download our Official App from Google Play.

Visual BASIC Program Page 3

Visual BASIC Program Page 3

Visual BASIC Program Page 3

To view other topics related to Computer. Click Here.

Visual BASIC Program to find the percentage through select case is?

Private Sub Command1_Click()

marks = InputBox("Enter obtained marks")

Select Case marks

Case Is < 33

MsgBox "Fail"

Case Is >= 33, Is <= 49

MsgBox "Third Division"

Case Is >= 50, Is <= 59

MsgBox "Second Division"

Case Is >= 60

MsgBox "First Division"

Case Else

MsgBox "Not a valid marks percentage"

End Select

End Sub

Visual BASIC Program to find the factorial by using next loop statements.

Private Sub Command1_Click()

Dim f As Long, n As Long, i As Long

n = InputBox("Enter as integer", "Factorial")

f = 1

For i = n To 1 Step -1

f = f * i

Next

MsgBox ("Factorial of " & n & "is" & f)

End Sub



Visual BASIC Program to find sum of first ten even numbers.

Private Sub Command1_Click()

Dim r As Integer

Dim n As Integer

Dim s As Integer

s = 0

n = 1

Do

r = n Mod 2

If r = o Then s = s + n

n = n + 1

Loop While n <= 10

MsgBox ("Sum of first ten even number is " & s)

End Sub

Visual BASIC Program to print first ten natural number on the screen.

Private Sub Command1_Click()

Dim a As Integer

n = 1

Do Until n > 10

Print n

n = n + 1

Loop

End Sub

Visual BASIC Program to find the days of week through select statement

Private Sub Command1_Click()

week = InputBox("Enter No of day")

Select Case week

Case 1

MsgBox "Monday"

Case 2

MsgBox "Tuesday"

Case 3

MsgBox "Wednesday"

Case 4

MsgBox "Thursday"

Case 5

MsgBox "Friday"

Case 6

MsgBox "Saturday"

Case 7

MsgBox "Sunday"

Case Else

MsgBox "Not a valid day number"

End Select

End Sub

Visual BASIC Program to find factorial of a given number.

Private Sub Command1_Click()

Dim f As Long, n As Long

n = InputBox("enter as integer", "Factorial")

f = 1

Do While n > 1

f = f * n

n = n - 1

Loop

MsgBox ("Factorial of the integer is " & f)

End Sub

Visual BASIC Program to print tables of a given number.

Private Sub Command1_Click()

Dim t As Integer

Dim n As Integer

t = InputBox("Enter number to print table")

Form1.Caption = "table of " & t

n = 1

Cls

While n <= 10

Print t, "X", n, "=", t * n

n = n + 1

Wend

End Sub

Visual BASIC Program to find grade

Private Sub Command1_Click()

Dim a As Integer

Dim b As Integer

Dim c As Integer

Dim d As Integer

Dim e As Integer

a = InputBox("Enter first value", "first value")

b = InputBox("Enter second value", "second value")

c = InputBox("Enter third value", "third value")

d = InputBox("Enter fourth value", "fourth value")

e = InputBox("Enter fifth value", "fifth value")

If a < 70 Then

MsgBox ("Fail")

ElseIf a < 80 Then

MsgBox ("Grade=c")

ElseIf a < 90 Then

MsgBox ("Grade=b")

Else

MsgBox ("Grade=a")

End If

End Sub

Post a Comment

Previous Post Next Post