Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Console.Write to TextBox

Console.Write to TextBox

Scheduled Pinned Locked Moved Visual Basic
helpquestiondiscussion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    japel
    wrote on last edited by
    #1

    Hello In the below code I found on the internet I would like to use in a vb app and have the result in a multi line text box but I Console.Write line gives me an error. I Tryed Textbox1.Text = ("IP Address {0}: {1} ", i, IpA(i).ToString)& VbCrlf Any thoughts? If there is better code out there that might also get subnet and gateway that would be great. Thanks Heaps 'To get local address Dim sHostName As String Dim i As Integer sHostName = Dns.GetHostName() Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName) Dim IpA() As IPAddress = ipE.AddressList For i = 0 To IpA.GetUpperBound(0) Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString) Next

    When people make you see red, be thankful your not colour blind.

    C G 2 Replies Last reply
    0
    • J japel

      Hello In the below code I found on the internet I would like to use in a vb app and have the result in a multi line text box but I Console.Write line gives me an error. I Tryed Textbox1.Text = ("IP Address {0}: {1} ", i, IpA(i).ToString)& VbCrlf Any thoughts? If there is better code out there that might also get subnet and gateway that would be great. Thanks Heaps 'To get local address Dim sHostName As String Dim i As Integer sHostName = Dns.GetHostName() Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName) Dim IpA() As IPAddress = ipE.AddressList For i = 0 To IpA.GetUpperBound(0) Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString) Next

      When people make you see red, be thankful your not colour blind.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      It would have been a lot helpful if you had mentioned anything about what kind of error you get. The call to Console.Write uses formatting, so you have to use String.Format when you want to do the same: Textbox1.Text = String.Format("IP Address {0}: {1} ", i, IpA(i).ToString) & VbCrlf

      --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • J japel

        Hello In the below code I found on the internet I would like to use in a vb app and have the result in a multi line text box but I Console.Write line gives me an error. I Tryed Textbox1.Text = ("IP Address {0}: {1} ", i, IpA(i).ToString)& VbCrlf Any thoughts? If there is better code out there that might also get subnet and gateway that would be great. Thanks Heaps 'To get local address Dim sHostName As String Dim i As Integer sHostName = Dns.GetHostName() Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName) Dim IpA() As IPAddress = ipE.AddressList For i = 0 To IpA.GetUpperBound(0) Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString) Next

        When people make you see red, be thankful your not colour blind.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        japel wrote:

        Any thoughts?

        First, if you get an error, tell us what it is.

        japel wrote:

        Textbox1.Text = ("IP Address {0}: {1} ", i, IpA(i).ToString)& VbCrlf

        That's never going to work.  Console.Write obviously has an overload to take a formatted string. Textbox1.Text = string.Format("IP Address {0}: {1} ", i, IpA(i).ToString) Will put one IP address in there.  Use a string builder to build a string of multiple addresses and set that to the textbox text, using string.Format as I have done. Overall, I suggest instead of looking for code on the web, you work through a book and learn some basic programming.  A basic understannding of VB.NET would have made clear to you what was happening here, that you can't format a string that way, without calling a format method ( as Console.WriteLine is doing ).

        Christian Graus - C++ MVP

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups