String.Format Help Please

  • Thread starter Thread starter Brian P. Hammer
  • Start date Start date
B

Brian P. Hammer

All - I am trying to name the column headers of a Component One Flex. What I
want to do is to name it much like the column names you'd find in Excel:
A,B, C.... AA, AB, AC and so on. I am trying this:

For c = 1 To flex.Cols.Count - 1
Dim hdr As String = String.Format("{0}", CChar("A"c + c - 1))
flex(0, c) = hdr
Next c

..Net does not like the + and it says Operator is not defined for types Char
and Integer. Any help would be appreciated.
Thanks,
Brian
 
Hi Brian,

You might find it easier to forget about String.Format and use regular String concatenation.

As for adding char and integer, the + operator will upgrade the result to at least integer so you need to cast it back to char

[C#]
char c = 'A';
int i = 2;
char d = (char)(c + i);
 
Brian P. Hammer said:
What I want to do is to name it much like the column names you'd find in
Excel: A,B, C.... AA, AB, AC and so on. I am trying this:

For c = 1 To flex.Cols.Count - 1
Dim hdr As String = String.Format("{0}", CChar("A"c + c - 1))
flex(0, c) = hdr
Next c

.Net does not like the + and it says Operator is not defined for types
Char and Integer. Any help would be appreciated.

\\\
Const A As Integer = AscW("A"c)
Dim Text As String = ChrW(A + i)
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top