Visual Basic 6.0
Slip2
Q.1) Write a VB Program to find Sum of digit of a given number till it reduces to single digit.
Accept input through textbox and Display the output in Message Box (using function) [15 Marks]
Solution
Private Sub Command1_Click()
Call A
End Sub
Function A()
Dim n As Integer
Dim s As Integer
s = 0
n = Val(Text1.Text)
While n > 0
s = s + (n Mod 10)
n = n \ 10
Wend
MsgBox ("sum of digits" & s)
End Function
![]() |
Sum of Digit |
Q.2) Write a VB Program for Dental Payment Form. Calculate total on selected options from
check boxes.[25 Marks]
Solution
Private Sub Command1_Click()
If Check1.Value = 1 Then
Text2.Text = 35
Else
Text2.Text = 0
End If
If Check2.Value = 1 Then
Text3.Text = 150
Else
Text3.Text = 0
End If
If Check3.Value = 1 Then
Text4.Text = 85
Else
Text4.Text = 0
End If
If Check4.Value = 1 Then
Text5.Text = 50
Else
Text5.Text = 0
End If
If Check5.Value = 1 Then
Text6.Text = 800
Else
Text6.Text = 0
End If
If Check6.Value = 1 Then
Text7.Text = Text7.Text
End If
Text8.Text = Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text) + Val(Text7.Text)
End Sub
Tags:
VB 6.0
Thanku
ReplyDelete