Link to home
Start Free TrialLog in
Avatar of itprochris
itprochris

asked on

Inserting Line

I am trying to make a simple code generator for my Database classes. I have the following code:
        Dim line As Integer = 0
        Me.OutputText.Lines(line).Insert(0, "Public Class CLASSNAME") 'i would have replaced the classname manually later
        line = line + 1
        Dim i As Integer = 0
        For i = 0 To i = (Me.DataGridView1.Rows.Count - 1)
            Me.OutputText.Lines(0).Insert(0, "Private _" + Me.DataGridView1.Rows(i).Cells(0).ToString + " as " + Me.DataGridView1.Rows(i).Cells(1).ToString)
            i = i + 1
            line = line + 1
        Next

What I am trying to do is have my datagrid's rows create a variable declare statement each on a seperate line in the OutputText textbox. What is wrong with this code? It says that the index is outside of the bounds of the array. And also, what can I do to make this more efficient? Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itprochris
itprochris

ASKER

Does this post each new "Private _whatever as whatever" on a new line?

Thanks!
Well, the vbCrLf constant is a "visual basic carriage return line feed" character -- equivalent to Chr(10) & Chr(13) -- which is a new line. :)

Now..... if your textbox is sized such that there's only one line visible... you'll have to resize it.

Also... is there a reason you're not Using something like a listbox to display the data?
I am getting errors on the last line that says that the index is outside of the bounds of the array. Could it be because I am using VB.NET 2005 Express Beta?

Also, I am not using a listbox because I need to be able to copy the output.

Thanks
Nevermind, I figured out the problem .Thanks for the help!
If you figured out the problem, you ought to post the solution here... in case someone else has the same problem...