PRINTING TO CONSOLE

I AM TRYING TO USE THE CONSOLE.WRITELINE FUNCTION USING VB 2005 EXPRESS. I WANT TO DISPLAY 2 OR MORE VARIABLES ON A SINGLE LINE . I WOULD LIKE TO BE ABLE TO CONTROL THE SPACING BETWEEN THE VARIABLES. IF THIS CAN BE DONE WITH THIS FUNCITION WHAT IS THE CORRECT SYNTAX.  I HAVE ONLY SEEN SINGLE VARIABLES USED IN DOCUMENTATION.


Answer this question

PRINTING TO CONSOLE

  • Giritharan

    You can control the cursor position of the console with this....
     Console.SetCursorPosition(column, row)


    If you want to print 2 variables on the same line, try something like...
    Console.Write("variable1 " & var1 & vbTab & "Variable2 " & var2)


    You can always pass vbTab for tab character, and vbNewLine for a new line.

    Dustin.


  • madhurieerupula

    Console.WriteLine supports the same syntax as String.Format, so you can write:



    Console.WriteLine("Var1 = {0,20} Var2 = {1,30}", var1, var2)

     


    The values of the variables will be inserted at the specified positions ({0}, {1} and so on), while the (optional) number after the comma defines how many columns will be used.

  • PRINTING TO CONSOLE