创建使用Visual Studio的字母效应(Creating a by letter effect

2019-10-19 05:35发布

我想创建与每个字母出现之间存在一定的时间由字母在Visual Studio中的效果,其中的文字不是一次全部显示在屏幕上,但信。 我打算开个不同的模块,将在此代码从我的主模块。 有任何想法吗? 这里是我的代码至今。 我想提出一个命令提示符。

Public Sub Main()
    Dim line As String
    Console.Title = "Command"
    Console.WriteLine("Microsoft Windows [Version 6.3.9600]")
    Console.WriteLine("<c> 2013 Microsoft Corporation. All right reserved.")
    Console.WriteLine(" ")
    Do
        Console.Write("C:\Users\Bob>")
        Line = Console.ReadLine()
        If line = "help" Then
            Console.WriteLine("hello world")
            Console.WriteLine(" ")
        ElseIf line = "help1" Then
            Console.WriteLine("hello again, world!")
            Console.WriteLine(" ")
        ElseIf line = "exit" Then
            Environment.Exit(0)
        Else
            Console.WriteLine("Command not found.")
            Console.WriteLine(" ")
        End If
    Loop While line IsNot Nothing
End Sub

Answer 1:

只需更换所有的Console.WriteLineMarquee("Text here")

更新 :由于沃尔特在应该注意,直到文本已完成显示这种做法将锁定应用程序的评论指出。 如果这不是想要的,那么你应该想想卸载到另一个线程或创建一个定时器事件。

     Sub Main()

            Marquee("Hello World")
            Console.ReadLine()

    End Sub

    Sub Marquee(StringToWrite As String)

        For i As Integer = 0 To StringToWrite.Length - 1
            Console.Write(StringToWrite.Substring(i, 1))
            Threading.Thread.Sleep(200)
        Next



    End Sub


Answer 2:

Windows窗体应用程序,我最好的拍摄是这样的:

Public Class Form1
    Dim M As Integer = 1
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim T As String = "" + TextBox1.Text
        Label1.Text = Label1.Text + Mid(T, M, 1)
        M = M + 1
    End Sub
    'You can use any trigger here
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub
End Class


文章来源: Creating a by letter effect with visual studio