Meraj99 Meraj99 - 14 days ago 6
Vb.net Question

How to center text in VB.net? (Console)

I want to print text "TEST" (Console.WriteLine) in the center of my VB.net console application. How would I go about doing so?

Looking for 'beginner-friendly' answers.

Answer

You'll need to get the console with, get the length of the string you're about to display and, subtract the second from the first, divide this in half and pad the string with this number of spaces.