Console: WriteValue

WriteValue

Writes a string to the Console output stream without a NewLine break.



 Public Sub WriteValue(
	  ByRef Value As Variant,
	  ParamArray args ( ) As Variant )

Parameters

Value
[ByRef] Variant. The value to write the string version of to the output stream.
args
[ByRef] Variant. Values to be used in a formatted output.

Remarks

Values are converted to their string representation for text output. A formatted output can be created similar to cString.Format.

Example

In this example, the WriteValue function is used to display a sequenceof values. The values are all written to the same line because WriteValuedoes not include a NewLine character after writing a value. A NewLinecharacter has to be manually added to advance to the next line.
Private Sub Main()    Dim i As Long        ' Writes out a sequence of digits. The digits    '' are written on the same line.    Console.WriteValue "Loop 1: "    For i = 1 To 5        Console.WriteValue i    Next i        '' Writes out a new line manually.    Console.WriteValue vbCrLf        '' Writes formatted values on the same line.    Console.WriteValue "Loop 2: "    For i = 1 To 5        Console.WriteValue "i = {0}" & IIf(i < 5, ", ", ""), i    Next i    '' The outputs from the loops are'' Loop 1: 12345'' Loop 2: i = 1, i = 2, i = 3, i = 4, i = 5End Sub
As shown, the first loop writes 5 digits to the console, each digitfollowing the previous digit on the same line. WriteValue does notinclude line-breaks. A manual line-break is written to achieve theeffect of advancing to the next line. The second loop uses a formattedvalue output. The argument is substituted in the formatted value andthen written to the output onto the same single line. A comma is addedto distinguish each iteration though the loop.

See Also

Project VBCorLib Overview Class Console Overview Console Properties Console Methods WriteLine