Entry aircraft

来源:互联网 发布:windows phone 8商店 编辑:程序博客网 时间:2024/05/29 03:17
Option Explicit
Dim arrstrAirCraft(), arrstrDate(), lngCount, lngIndex
lngCount = GetCount
For lngIndex = 0 To lngCount - 1
    ReDim Preserve arrstrAirCraft(lngIndex)
    arrstrAirCraft(lngIndex) = GetName(lngIndex + 1)
Next
SortIndex
ShowAirCraft
'****************************************************************************
Sub SortIndex
    Dim datIndex, lngNumber, EveryNumber, boolLoopAgain
    ReDim arrstrCheck(lngIndex - 1)
    For datIndex = 0 To lngIndex - 1
        Do
            boolLoopAgain = False
            lngNumber = RandomNumber
            For Each EveryNumber In arrstrCheck
                If CStr(lngNumber) = EveryNumber Then
                    boolLoopAgain = True
                    Exit For
                End If
            Next
        Loop While boolLoopAgain
        ReDim Preserve arrstrDate(datIndex)
        arrstrDate(datIndex) = lngNumber
        arrstrCheck(datIndex) = lngNumber
    Next
End Sub
Sub ShowAirCraft
    Dim strResult, datIndex
    For datIndex = 0 To lngIndex - 1
        strResult = strResult & arrstrAirCraft(arrstrDate(datIndex)) & "/"
    Next
    strResult = Left(strResult, Len(strResult) - 1)
    MsgBox strResult
End Sub
'****************************************************************************
Function RandomNumber
    Randomize
    RandomNumber = Round((lngIndex - 1) * Rnd)
End Function
Function GetName(Counter)
    Dim intButton, boolLoopAgain
    Do
        boolLoopAgain = False
        GetName = InputBox("Please entry the aircraft name.", Counter)
        If GetName = Empty Then
            intButton = MsgBox("Forbid nothing. Again?", vbYesNo)
            If intButton = 6 Then boolLoopAgain = True
            If intButton = 7 Then WScript.Quit
        End If
    Loop While boolLoopAgain
End Function
Function GetCount
    Dim intButton, boolLoopAgain
    Do
        boolLoopAgain = False
        GetCount = InputBox("How many aircraft name do you want to entry?")
        If Not IsNumeric(GetCount) Or GetCount = Empty Then
            intButton = MsgBox("The count can't be word. Again?", vbYesNo)
            If intButton = 6 Then boolLoopAgain = True
            If intButton = 7 Then WScript.Quit
        Else
            GetCount = Round(GetCount)
        End If
    Loop While boolLoopAgain
End Function
原创粉丝点击