How to Modify The name of Header Listbox with FOR Instruction

Hi All!

I Have this code, for a method called: PopulateListBox:

If rs Is Nil Then Return

// set up listbox state for population
dataList.DeleteAllRows
dataList.Columncount = rs.Fieldcount

// Add the DB columns as the headers for the ListBox
datalist.HasHeading = True
dataList.ColumnCount = rs.FieldCount
dataList.Column(-1).WidthExpression = “100”
For i As Integer = 0 To rs.FieldCount-1
dataList.Heading(i) = rs.IdxField(i+1).Name
Next

// Add the data from the table
While Not rs.EOF
dataList.AddRow("")

For i As Integer = 0 To rs.FieldCount-1
  dataList.Cell(dataList.LastIndex, i) = rs.IdxField(i+1).StringValue
Next

rs.MoveNext

Wend

Now I have an Issue, How can I replace a character in the Name of the Headers?
So, This is the names of my headers on the Database:

XML, Emmiter-Name, RFC-Emitter-Name, TAX-Rate, TAX-Rate-11.
With the Code This name are display in the headers in the listbox.

But I want to know How can I replace the “-” character with " " space character.
In order to display the headers on the listbox like this:

XML, Emmiter Name, RFC Emitter Name, TAX Rate, TAX Rate-11.

I’m thinking on the loop:
For i As Integer = 0 To rs.FieldCount-1
dataList.Heading(i) = rs.IdxField(i+1).Name
Next

I dunno if there’s a way to process the rs.IdxField(x).name,to behave like: If rs.IdxField(i+1).Name have “-” then replace with " ".

Is this posible? How?

Thanks

dataList.Heading(i) = rs.IdxField(i+1).Name.Replace("-", " ")

Thanks man :stuck_out_tongue:

MMM. I think It was possible to Assign Name of the SQL Columns in the Database with “-” like:

Emitter-Name instead of EmitterName.

That was my idea, because I know that Its impossible or it make problem to Have Headers name with Spaces,like: Emitter Name

Now the issue is that I named with “-” like separators but It got me Sql Syntax Error, I think that this “-” character its not supported no set names.

I probed with “?” and it does the same. :frowning: :frowning:

I got the solution “_” is supported

It works for names like:

Emitter_Name = Emiter Name ----OK
but when I got names with “" two times, only one "” is processed like:

Tax_Rate_16 = Tax Rate_16

[quote=190326:@Gerardo García]It works for names like:

Emitter_Name = Emiter Name ----OK
but when I got names with “" two times, only one "” is processed like:

Tax_Rate_16 = Tax Rate_16[/quote]
I got it:

dataList.Heading(i) = rs.IdxField(i+1).Name.ReplaceAll("_", " ")

ReplaceAll is the solution.

In Fact,language documentation is very useful