用视觉工作室创建一个字母效果 [英] Creating a by letter effect with visual studio

查看:193
本文介绍了用视觉工作室创建一个字母效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在视觉工作室中创建一个效果,其中文本不是一次全部显示在屏幕上,而是逐个字母,在每个字母之间出现一定时间。我打算打开一个不同的模块,将从我的主模块中有这个代码。有任何想法吗?这是我的编码到目前为止。

I would like to create an effect in visual studio where text shows up on the screen not all at once, but letter by letter with a certain amount of time between each letter appearing. I plan to open a different module that will have this code in it from my main module. Any ideas? Here is my coding so far. I am making a command prompt.

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


推荐答案

只需替换 Console.WriteLine Marquee(Text here)

更新:Walt指出应该注意的注释,这种方法将锁定应用程序,直到文本完成显示。如果这不是所期望的,那么你应该考虑将其卸载到另一个线程或创建一个计时器事件。

Update: As Walt points out in the comments it should be noted this approach will lock up the application until the text has finished displaying. If this is not desired then you should think about offloading it to another thread or creating a timer event.

     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

这篇关于用视觉工作室创建一个字母效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆