How to Output a String in Visual Basic


In computer programming, the String variable is widely used to capture and output data among variables or controls. In Visual Basic, you can use the "ToString" method to output a String value to a String variable. This method is useful when you're using Double data types for mathematical operations and the output needs to be a String. You can also use this method to parse a string before it's displayed to the user.

  • Launch Microsoft Visual Basic Express, click "New Project..." on the left pane of your screen. Select "Console Application." Click "OK" to create a new console project.

  • Type the following code to declare a Double and a String variable:

    Dim myNumber As Double = 52.2

        Dim myString As String
  • Add the following code to convert the numeric value to its equivalent string representation and output the string using a message box:

    myString = myNumber.ToString()

  • Click the "Debug" menu and click "Start Debugging" to run your program.

Related Searches


  • Photo Credit Stockbyte/Stockbyte/Getty Images
Promoted By Zergnet


You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!