-2

わかりましたので、これまでの私のコードは次のとおりです。

Module Module1
Public Event count()
Sub Main()
    AddHandler count, AddressOf MyFunction
    Console.WriteLine("to start the countdown process type go")
    Console.ReadLine()
    If e.KeyCode = Keys.Enter Then
        RaiseEvent count()
    End If
    Console.ReadKey()
End Sub
Sub MyFunction()
    Dim a As Integer = 16
    Dim b As Integer = 6
    Console.WriteLine("Now we are going to count to a number using only even numbers")
    Do Until b > a
        Console.WriteLine(b)
        b += 2
    Loop
    Console.ReadKey()
End Sub
End Module

エンターキーが押されたときにイベントカウントを上げようとしています。私は何を間違っていますか?

4

2 に答える 2

1
Module Module1

    Public Event count()
    Sub Main()
        AddHandler count, AddressOf MyFunction
        Console.WriteLine("to start the countdown process type go")
        Dim input As String = Console.ReadLine() 'Already waits for 'enter'
        RaiseEvent count()


        Console.WriteLine("Press any key to exit...")
        Console.ReadKey()
    End Sub
    Sub MyFunction()
        Dim a As Integer = 16
        Dim b As Integer = 6
        Console.WriteLine("Now we are going to count to a number using only even numbers")
        Do Until b > a
            Console.WriteLine(b)
            b += 2
        Loop
        Console.ReadKey()
    End Sub

End Module
于 2014-05-12T18:33:49.317 に答える