Dim strTotalLineLength, intTotalLineLength, strRcptSentence
runAll
'******************************************************************************
Sub runAll
promptLineLength
promptRcptSentence
MsgBox(findStartPoint(intTotalLineLength,strRcptSentence))
End Sub
'*******************************************************************
'******************************************************************************
Sub promptLineLength
strTotalLineLength = InputBox("Enter Total Line Length")
checkMeNumeric(strTotalLineLength)
checkMeEmpty(strTotalLineLength)
convertStringToInteger(strTotalLineLength)
End Sub
'*******************************************************************
'******************************************************************************
Sub promptRcptSentence
strRcptSentence = InputBox("Enter Your Receipt Sentence")
checkMeEmpty(strRcptSentence)
End Sub
'*******************************************************************
'******************************************************************************
Sub convertStringToInteger(linelength)
If Len(linelength) > 7 Then
MsgBox "Your Number is too Large!"
promptLineLength
Exit Sub
Else
intTotalLineLength = CInt(linelength)
If intTotalLineLength > 1000 Or intTotalLineLength < 0 Then
quitscript
End If
End If
End Sub
'*******************************************************************
'******************************************************************************
Function findStartPoint(linelength,rcptsentence)
intLengthRcptSentence = Len(rcptsentence)
intMiddlePoint = Int(linelength / 2)
intBackspaceBy = Int(intLengthRcptSentence / 2)
intStartWritingHere = (intMiddlePoint - intBackspaceBy)
findStartPoint = intStartWritingHere _
& " <----- Start Writing your sentence here"
End Function
'*******************************************************************
'******************************************************************************
Sub checkMeEmpty(x)
If x = "" Then
quitscript
End If
End Sub
'*******************************************************************
'******************************************************************************
Sub checkMeNumeric(x)
If Not IsNumeric(x) Then
MsgBox "Enter Numbers Only!"
promptLineLength
End If
End Sub
'*******************************************************************
'******************************************************************************
Sub quitscript
MsgBox "Quitting Now"
Wscript.Quit
End Sub
'*******************************************************************
Friday, December 16, 2005
Find Middle Point
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment