by Buddhika Fernando (9 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Mon 4th July 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Task Find Your Lucky No Using Birthday Enjoy Your Codes
API Declarations
Task Find Your Lucky No Using Birthday
Rem Developed By Buddhika Fernando
Rem [email protected] , [email protected]
Rem Declare Variables
Dim I, X, Lenth, XLenth
On Error Resume Next
Rem Get The Lenght Of Text
Lenth = Len(Text1.Text)
Rem Calculate The Value
Rem Eg : 28011981
Rem For Loop Calculatuing Like This
Rem 2+8+0+1+1+9+8+1
For I = 1 To Lenth
X = Val(X) + Val(Mid(Trim(Text1.Text), I, 1))
Next I
Rem Get Yhe Lenght Of Answer
XLenth = Len(X)
Rem Calculate The Final Answer Until
Rem Answer Lenght = 1
Do Until Len(XLenth) > 2
X = Val(Mid(Trim(X), 1, 1)) + Val(Mid(Trim(X), 2, 1))
If Len(X) = 1 Then X = X: Exit Do
Loop
Rem Display Your Lucky No
MsgBox "Your Lucky No Is [ " & X & " ] ", vbInformation + vbOKOnly, "Lucky No"
Text1.SetFocus
End Sub
Private Sub Text1_Change()
On Error Resume Next
Rem Display Form Caption With Birthday
Rem Using Left,Right And Mid Function
Select Case Len(Text1.Text)
Case 0: Me.Caption = "Get My Lucky No "
Case 1: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 1)
Case 2: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 2)
Case 3: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 2) & "/" & Right(Text1.Text, 1)
Case 4: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 2) & "/" & Right(Text1.Text, 2)
Case 5: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 2) & "/" & Mid(Text1.Text, 3, 2) & "/" & Right(Text1.Text, 1)
Case 6: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 2) & "/" & Mid(Text1.Text, 3, 2) & "/" & Right(Text1.Text, 2)
Case 7: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 2) & "/" & Mid(Text1.Text, 3, 2) & "/" & Right(Text1.Text, 3)
Case 8: Me.Caption = "Get My Lucky No " & Left(Text1.Text, 2) & "/" & Mid(Text1.Text, 3, 2) & "/" & Right(Text1.Text, 4)
End Select
Rem Check Text Lenght
If Len(Text1.Text) <> 8 Then CmdGet.Enabled = False Else CmdGet.Enabled = True
End Sub
Private Sub Text1_GotFocus()
With Text1
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub