Entry aircraft

本文介绍了一个使用VBScript实现的简单程序,该程序允许用户输入若干飞机名称,并通过随机数生成器对这些名称进行随机排序。程序还包括了输入验证功能,确保用户输入的是有效的数值和非空字符串。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值