Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Saturday, July 16, 2011

VB-44 : Reverse a given 5 digit number

Design a VB application to reverse the digits of a given 5 digit number.

Compare the same program I did in JAVA , the link is Reverse a number

Refer Reverse a String also.

A)    Program Design : 

(B) Property(Controls Used) :
  • 3 Labels with Captions  are Reverse Number,Enter any 5 digit number and Reverse Number is.
  • 2 Text Boxes ,Text property of both should be Zero, and the Locked Property of the second text box  (text2, to reverse the digits) must be true
  • One Command Button with Caption Reverse.

(C) Attaching Code to the Object :
Private Sub Command1_Click()
rev_no
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
SendKeys (Char(8))
End If
End Sub
Private Sub Text1_Change()
If Val(Text1.Text) > 99999 Then
SendKeys (Char(8))
End If
End Sub
Private Sub rev_no()
Dim rev As Integer
old = Val(Text1.Text)
While (Round(old) > 0)
rev = rev * 10 + old Mod 10
old = old / 10
Wend
End Sub





Possible Error  : Sub or function not defined

====================================================================
===========================================================

No comments: