vb System.Console.ReadLine类(方法)实例源码

下面列出了vb System.Console.ReadLine 类(方法)源码代码实例,从而了解它的用法。

作者:VB.NET开发    项目:Syste   
' 导入命名空间
Imports System.IO

Public Module InsertTabs
    Private Const tabSize As Integer = 4
    Private Const usageText As String = "Usage: INSERTTABS inputfile.txt outputfile.txt"
   
    Public Function Main(args As String()) As Integer
        If args.Length < 2 Then
            Console.WriteLine(usageText)
            Return 1
        End If
      
        Try
            ' Attempt to open output file.
            Using writer As New StreamWriter(args(1))
                Using reader As New StreamReader(args(0))
                    ' Redirect standard output from the console to the output file.
                    Console.SetOut(writer)
                    ' Redirect standard input from the console to the input file.
                    Console.SetIn(reader)
                    Dim line As String = Console.ReadLine()
                    While line IsNot Nothing
                        Dim newLine As String = line.Replace("".PadRight(tabSize, " "c), ControlChars.Tab)
                        Console.WriteLine(newLine)
                        line = Console.ReadLine()
                    End While
                End Using
            End Using
        Catch e As IOException
            Dim errorWriter As TextWriter = Console.Error
            errorWriter.WriteLine(e.Message)
            errorWriter.WriteLine(usageText)
            Return 1
        End Try

        ' Recover the standard output stream so that a 
        ' completion message can be displayed.
        Dim standardOutput As New StreamWriter(Console.OpenStandardOutput())
        standardOutput.AutoFlush = True
        Console.SetOut(standardOutput)
        Console.WriteLine($"INSERTTABS has completed the processing of {args(0)}.")
        Return 0
    End Function 
End Module

作者:VB.NET开发    项目:Syste   
Module Example
   Public Sub Main()
      Console.Clear()

      Dim dat As Date = Date.Now

      Console.WriteLine()
      Console.WriteLine("Today is {0:d} at {0:T}.", dat)
      Console.WriteLine()
      Console.Write("Press any key to continue... ")
      Console.ReadLine()
   End Sub
End Module

作者:VB.NET开发    项目:Syste   
Module Example
   Public Sub Main()
      If Not Console.IsInputRedirected Then
         Console.WriteLine("This example requires that input be redirected from a file.")
         Exit Sub 
      End If

      Console.WriteLine("About to call Console.ReadLine in a loop.")
      Console.WriteLine("----")
      Dim s As String
      Dim ctr As Integer
      Do
         ctr += 1
         s = Console.ReadLine()
         Console.WriteLine("Line {0}: {1}", ctr, s)
      Loop While s IsNot Nothing
      Console.WriteLine("---")
   End Sub
End Module

作者:VB.NET开发    项目:Syste   
Module Example
   Public Sub Main()
      Dim line As String
      Console.WriteLine("Enter one or more lines of text (press CTRL+Z to exit):")
      Console.WriteLine()
      Do 
         Console.Write("   ")
         line = Console.ReadLine()
         If line IsNot Nothing Then Console.WriteLine("      " + line)
      Loop While line IsNot Nothing   
   End Sub
End Module
' The following displays possible output from this example:
'       Enter one or more lines of text (press CTRL+Z to exit):
'       
'          This is line #1.
'             This is line #1.
'          This is line #2
'             This is line #2
'          ^Z
'       
'       >

作者:VB程序    项目:Syste   
Module Module1
    Sub Main()
        Dim strMessage As String
        Try
            strMessage = Console.ReadLine()
            Console.WriteLine("HELLO " + strMessage)
        Catch ex As Exception
        End Try
    End Sub
End Module


问题


面经


文章

微信
公众号

扫码关注公众号