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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Help! convert this piece of code to VB.NET [modified]

Help! convert this piece of code to VB.NET [modified]

Scheduled Pinned Locked Moved Visual Basic
csharpc++help
7 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.
  • S Offline
    S Offline
    Sergi25
    wrote on last edited by
    #1

    Can somebody help me with this code. I need a VB.net equivanlent. string fn = @"c:\temp\data.txt"; using (System.IO.StreamReader sr = new System.IO.StreamReader(fn)) { **for (int row = this.c1FlexGrid1.Rows.Fixed; sr.EndOfStream == false; row++) { string line = sr.ReadLine(); if (row >= this.c1FlexGrid1.Rows.Count) this.c1FlexGrid1.Rows.Count++; int col = this.c1FlexGrid1.Cols.Fixed; string[] cells = line.Split(' '); for (int c = 0; c < cells.Length; c++) { if (col >= this.c1FlexGrid1.Cols.Count) this.c1FlexGrid1.Cols.Count++; this.c1FlexGrid1[row, col] = cells[c]; col++; }**} } I need the loops mainly Thanks -- modified at 21:10 Sunday 28th January, 2007

    C D 2 Replies Last reply
    0
    • S Sergi25

      Can somebody help me with this code. I need a VB.net equivanlent. string fn = @"c:\temp\data.txt"; using (System.IO.StreamReader sr = new System.IO.StreamReader(fn)) { **for (int row = this.c1FlexGrid1.Rows.Fixed; sr.EndOfStream == false; row++) { string line = sr.ReadLine(); if (row >= this.c1FlexGrid1.Rows.Count) this.c1FlexGrid1.Rows.Count++; int col = this.c1FlexGrid1.Cols.Fixed; string[] cells = line.Split(' '); for (int c = 0; c < cells.Length; c++) { if (col >= this.c1FlexGrid1.Cols.Count) this.c1FlexGrid1.Cols.Count++; this.c1FlexGrid1[row, col] = cells[c]; col++; }**} } I need the loops mainly Thanks -- modified at 21:10 Sunday 28th January, 2007

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

      Which bit are you stuck on ? I don't think VB.NET supports 'using', that just means you create the object, and call Dispose at the end of your code block.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      S 1 Reply Last reply
      0
      • C Christian Graus

        Which bit are you stuck on ? I don't think VB.NET supports 'using', that just means you create the object, and call Dispose at the end of your code block.

        Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

        S Offline
        S Offline
        Sergi25
        wrote on last edited by
        #3

        I mainly need the loops -- modified at 21:24 Sunday 28th January, 2007

        C 1 Reply Last reply
        0
        • S Sergi25

          I mainly need the loops -- modified at 21:24 Sunday 28th January, 2007

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

          Let me see how I go... Dim row as int = **this.c1FlexGrid1.Rows.Fixed; while (sr.EndOfStream = false) dim line as string = sr.ReadLine()** **if (row >= c1FlexGrid1.Rows.Count) then     c1FlexGrid1.Rows.Count++ dim col as int = c1FlexGrid1.Cols.Fixed dim cells as string() = line.Split(' ') dim c as int for c = 0 to cells.Length     if col >= c1FlexGrid1.Cols.Count then         c1FlexGrid1.Cols.Count++     c1FlexGrid1(row, col) = cells(c);     col++;** end for **row = row + 1 end while** A bit of a guess, but I'd say this is more suited to the while loop anyhow.

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          S 1 Reply Last reply
          0
          • C Christian Graus

            Let me see how I go... Dim row as int = **this.c1FlexGrid1.Rows.Fixed; while (sr.EndOfStream = false) dim line as string = sr.ReadLine()** **if (row >= c1FlexGrid1.Rows.Count) then     c1FlexGrid1.Rows.Count++ dim col as int = c1FlexGrid1.Cols.Fixed dim cells as string() = line.Split(' ') dim c as int for c = 0 to cells.Length     if col >= c1FlexGrid1.Cols.Count then         c1FlexGrid1.Cols.Count++     c1FlexGrid1(row, col) = cells(c);     col++;** end for **row = row + 1 end while** A bit of a guess, but I'd say this is more suited to the while loop anyhow.

            Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

            S Offline
            S Offline
            Sergi25
            wrote on last edited by
            #5

            Thanks Chris I'll give it a try.

            C 1 Reply Last reply
            0
            • S Sergi25

              Thanks Chris I'll give it a try.

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

              Ooops - I left a 'this'.  this is me in VB.NET.  As in me.Invalidate() - isn't it just the cutest thing ?

              Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

              1 Reply Last reply
              0
              • S Sergi25

                Can somebody help me with this code. I need a VB.net equivanlent. string fn = @"c:\temp\data.txt"; using (System.IO.StreamReader sr = new System.IO.StreamReader(fn)) { **for (int row = this.c1FlexGrid1.Rows.Fixed; sr.EndOfStream == false; row++) { string line = sr.ReadLine(); if (row >= this.c1FlexGrid1.Rows.Count) this.c1FlexGrid1.Rows.Count++; int col = this.c1FlexGrid1.Cols.Fixed; string[] cells = line.Split(' '); for (int c = 0; c < cells.Length; c++) { if (col >= this.c1FlexGrid1.Cols.Count) this.c1FlexGrid1.Cols.Count++; this.c1FlexGrid1[row, col] = cells[c]; col++; }**} } I need the loops mainly Thanks -- modified at 21:10 Sunday 28th January, 2007

                D Offline
                D Offline
                Dave Doknjas
                wrote on last edited by
                #7

                VB does have a 'using' equivalent. The equivalent VB is the following produced with Instant VB - note that the inner loop could have been converted to a VB 'For' loop instead as Christian's post indicated: Dim fn As String = "c:\temp\data.txt" Using sr As System.IO.StreamReader = New System.IO.StreamReader(fn) Dim row As Integer = Me.c1FlexGrid1.Rows.Fixed Do While sr.EndOfStream = False Dim line As String = sr.ReadLine() If row >= Me.c1FlexGrid1.Rows.Count Then Me.c1FlexGrid1.Rows.Count += 1 End If Dim col As Integer = Me.c1FlexGrid1.Cols.Fixed Dim cells As String() = line.Split(" "c) Dim c As Integer = 0 Do While c < cells.Length If col >= Me.c1FlexGrid1.Cols.Count Then Me.c1FlexGrid1.Cols.Count += 1 End If Me.c1FlexGrid1(row, col) = cells(c) col += 1 c += 1 Loop row += 1 Loop End Using

                David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Instant Python: C# to Python converter, VB to Python converter

                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