I'll bet there is a better way of doing this

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

I can't seem to get the one-line equivalent of this:
Dim tmp() As Integer = {100}

HistoryRichTextBox.SelectionTabs = tmp





This is a VB6 conversion. Is that still the way to do it?

Mid(aHistoryRichTextBox.Text, lLpCnt, 1) <> vbCr



So much has changed!





Thanks
 
Dim tmp() As Integer = {100}
HistoryRichTextBox.SelectionTabs = tmp(0)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
* " Just Me said:
I can't seem to get the one-line equivalent of this:
Dim tmp() As Integer = {100}

HistoryRichTextBox.SelectionTabs = tmp

\\\
HistoryRichTextBox.SelectionTabs = New Integer() {100}
///
 
Sorry, my response is incorrect, see Herfrieds for the correct
implementation. ( I didnt check the RTB property )


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
I wonder why you didn't answer the second question?

This is a VB6 conversion. Is that still the way to do it?
Mid(aHistoryRichTextBox.Text, lLpCnt, 1) <> vbCr


I know you both know the answer

Of course I appreciated anything I get - but I was wondering?

Thanks again for the help
 
Try....

aHistoryRichTextBox.Text.Substring(lLpCnt, 1) <> vbCrLf

Hope this helps.
 
Thanks to both

Guess I'm trying to do thing the "new" way and often am not sure.
 
Try....

aHistoryRichTextBox.Text.Substring(lLpCnt, 1) <> vbCrLf

aHistoryRichTextBox.Text.Substring(lLpCnt - 1, 1) <> vbCrLf

would be more accurate. Mid is one-based, .NET strings are 0-based.

That's one reason I think it's a good idea to get away from the legacy
functions as much as possible. The little things like index differences
will kill you.
 
David,

Which legacy functions, there are a lot of legacy functions imported from C
as well. Choose for yourself what are the good ones. That is in my opinion a
better advice.

In my opinion are by instance the convert functions from VB very powerfull.

Cor
 
David,

Which legacy functions, there are a lot of legacy functions imported from C
as well. Choose for yourself what are the good ones. That is in my opinion a
better advice.

"Choose for yourself" is what everybody does eventually, of course, but
it doesn't provide much guidance for somebody new to the language. As
for which functions to avoid, I'd advise new users to avoid the
VisualBasic namespace as much as possible, and I find that even new
users have an intuitive sense of which functions are in there. If one
later decides that there's useful stuff in MS.VBasic, by all means go
ahead and use it, *after* you understand what the pitfalls and
trade-offs are.
 
There is one advantage in using the Left, Right, and Mid in that they are
somewhat forgiving. For example if you have variable length strings, the
string a = "123" when used as Left(a, 5) will give you "123" whereas
a.substring(0,5) will give you an exception.
 

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