4. Write a VB program to find sum of first and last digits of a given number. Display the output using msgbox.

Private Sub cmdClear_Click()
Text1.Text = “”
End Sub

Private Sub cmdDisplay_Click()
n = Val(Text1.Text)
l = Len(n)
cnt = 1
While n > 0
r = n Mod 10
n = n \ 10
If cnt = 1 Or cnt = l Then
s = s + r
End If
cnt = cnt + 1
MsgBox s, vbOKOnly, “Sum Of First & Last digits”
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub Form_Activate()
End Sub


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s