From: Rick Rothstein on
> I'm curious Rick, what do you consider to be your "best" one liner?

That is a hard question to answer as I have written so many one-liners
across the years. I would have to say my most "practical" one-liner would be
this one...

IsDigitsOnly = Len(Value) > 0 And Not Value Like "*[!0-9]*"

which overcomes the shortcomings of VB's built-in IsNumeric function when
testing a user's input (into say, a TextBox) to see if it consists of only
digits.

As for my most "obfuscated" one-liner, not so much for length as I have
written much longer ones; but, rather, more for the difficulty in figuring
out how it works, might be this one...

MakeOrdinal = Number & Choose(1 + Number * Abs(Partition(Number Mod _
100, 1, 13, 5) <> "11:13" And Partition(Number Mod 10, _
1, 9, 3) = " 1: 3") Mod 10, "th", "st", "nd", "rd")

which changes a number into its ordinal value (for example, 103 becomes
103rd where as 113 becomes 113th). I figure that the majority of the people
never knew there was a Partition function in VB and, after looking at the
help files for it, might still have trouble deciphering why it actually
works.

However, the one-liner I am most "proud" of is this one which I submitted to
John Walkenbach, a renown Excel author. He had this function listed on his
website (which I only just tripped across)...

Function ExactWordInString(Text As String, Word As String) As Boolean
Dim i As Long
Const Space As String = " "
Text = UCase(Text)
For i = 0 To 64
Text = Replace(Text, Chr(i), Space)
Next i
For i = 91 To 255
Text = Replace(Text, Chr(i), Space)
Next i
Text = Space & Text & Space
Word = UCase(Space & Word & Space)
ExactWordInString = InStr(Text, Word) <> 0
End Function

This function determines if a word exists with a larger piece of text as a
stand-alone word and not part of another word ("the" by itself as opposed to
those letters being in the middle of "mother" for example). Now, his
definition of what a delimiter is quite loose (any non-alpha character) so
"123the42" would count the word "the" as standing alone, but for normal
usage, this function would be fine. Anyway, I saw this function and thought
to myself "one-liner maybe?"; and here is what I came up with...

Function ExactWordInString(Text As String, Word As String) As Boolean
ExactWordInString = " " & UCase(Text) & " " Like _
"*[!A-Z]" & UCase(Word) & "[!A-Z]*"
End Function

Well, when John received this from me, he listed my function as an update to
his...

http://spreadsheetpage.com/index.php/tip/is_a_particular_word_contained_in_a_text_sring

and then posted in his blog...

http://spreadsheetpage.com/index.php/blog/improving_a_function/

that he was "humbled" by my solution. For a John Walkenbach to be "humble"
by my one-liner is a big deal (in my book at least), and so I am quite proud
of that one-liner. By the way, we can overcome the "123the456" problem easy
enough...

Function ExactWordInString(Text As String, Word As String) As Boolean
ExactWordInString = " " & UCase(Text) & " " Like "*[!A-Z0-9]" & _
UCase(Word) & "[!A-Z0-9]*"
End Function

but we are still left with what to do about the ASCII/ANSI characters with
values above 127. I figured John must have thought about the problem and
decided to settle on the non-alpha definition of a delimiter for practical
purposes, so I simply accepted his definition of delimiter and went with
that.

The above is the pretty much the only way I could decide on how to answer
your question as to which one-liner I consider my "best".

--
Rick (MVP - Excel)

From: Mike Williams on
"Scott M." <s-mar(a)nospam.nospam> wrote in message
news:%23ZSUW9cSKHA.1792(a)TK2MSFTNGP04.phx.gbl...

> What I think we're boiled down to here is that I know for
> a fact that a valuable learning tool is to provide comparisons
> to the concept being taught . . .

So why don't you go and teach Delphi or C++ or ASM or VB6 or Java on the
VB.Net group? The fact is that you are a troll, Scotty.

Mike



From: Henning on

"Mike Williams" <Mike(a)WhiskyAndCoke.com> skrev i meddelandet
news:e6c9mEpSKHA.1792(a)TK2MSFTNGP04.phx.gbl...
> "Scott M." <s-mar(a)nospam.nospam> wrote in message
> news:%23ZSUW9cSKHA.1792(a)TK2MSFTNGP04.phx.gbl...
>
>> What I think we're boiled down to here is that I know for
>> a fact that a valuable learning tool is to provide comparisons
>> to the concept being taught . . .
>
> So why don't you go and teach Delphi or C++ or ASM or VB6 or Java on the
> VB.Net group? The fact is that you are a troll, Scotty.
>
> Mike
>
>

Good point, I missed that one :)

Just hope he *did* throw in the towel, even though it's been amusing.

/Henning


From: Kevin Provance on
Wow. All very cool. Ever consider a blog of sorts to show off your one
liner work?

--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.

http://www.facebook.com/group.php?gid=43606237254
"Rick Rothstein" <rick.newsNO.SPAM(a)NO.SPAMverizon.net> wrote in message
news:edmU1IoSKHA.1232(a)TK2MSFTNGP05.phx.gbl...
|> I'm curious Rick, what do you consider to be your "best" one liner?
|
| That is a hard question to answer as I have written so many one-liners
| across the years. I would have to say my most "practical" one-liner would
be
| this one...
|
| IsDigitsOnly = Len(Value) > 0 And Not Value Like "*[!0-9]*"
|
| which overcomes the shortcomings of VB's built-in IsNumeric function when
| testing a user's input (into say, a TextBox) to see if it consists of only
| digits.
|
| As for my most "obfuscated" one-liner, not so much for length as I have
| written much longer ones; but, rather, more for the difficulty in figuring
| out how it works, might be this one...
|
| MakeOrdinal = Number & Choose(1 + Number * Abs(Partition(Number Mod _
| 100, 1, 13, 5) <> "11:13" And Partition(Number Mod 10, _
| 1, 9, 3) = " 1: 3") Mod 10, "th", "st", "nd", "rd")
|
| which changes a number into its ordinal value (for example, 103 becomes
| 103rd where as 113 becomes 113th). I figure that the majority of the
people
| never knew there was a Partition function in VB and, after looking at the
| help files for it, might still have trouble deciphering why it actually
| works.
|
| However, the one-liner I am most "proud" of is this one which I submitted
to
| John Walkenbach, a renown Excel author. He had this function listed on his
| website (which I only just tripped across)...
|
| Function ExactWordInString(Text As String, Word As String) As Boolean
| Dim i As Long
| Const Space As String = " "
| Text = UCase(Text)
| For i = 0 To 64
| Text = Replace(Text, Chr(i), Space)
| Next i
| For i = 91 To 255
| Text = Replace(Text, Chr(i), Space)
| Next i
| Text = Space & Text & Space
| Word = UCase(Space & Word & Space)
| ExactWordInString = InStr(Text, Word) <> 0
| End Function
|
| This function determines if a word exists with a larger piece of text as a
| stand-alone word and not part of another word ("the" by itself as opposed
to
| those letters being in the middle of "mother" for example). Now, his
| definition of what a delimiter is quite loose (any non-alpha character) so
| "123the42" would count the word "the" as standing alone, but for normal
| usage, this function would be fine. Anyway, I saw this function and
thought
| to myself "one-liner maybe?"; and here is what I came up with...
|
| Function ExactWordInString(Text As String, Word As String) As Boolean
| ExactWordInString = " " & UCase(Text) & " " Like _
| "*[!A-Z]" & UCase(Word) & "[!A-Z]*"
| End Function
|
| Well, when John received this from me, he listed my function as an update
to
| his...
|
|
http://spreadsheetpage.com/index.php/tip/is_a_particular_word_contained_in_a_text_sring
|
| and then posted in his blog...
|
| http://spreadsheetpage.com/index.php/blog/improving_a_function/
|
| that he was "humbled" by my solution. For a John Walkenbach to be "humble"
| by my one-liner is a big deal (in my book at least), and so I am quite
proud
| of that one-liner. By the way, we can overcome the "123the456" problem
easy
| enough...
|
| Function ExactWordInString(Text As String, Word As String) As Boolean
| ExactWordInString = " " & UCase(Text) & " " Like "*[!A-Z0-9]" & _
| UCase(Word) & "[!A-Z0-9]*"
| End Function
|
| but we are still left with what to do about the ASCII/ANSI characters with
| values above 127. I figured John must have thought about the problem and
| decided to settle on the non-alpha definition of a delimiter for practical
| purposes, so I simply accepted his definition of delimiter and went with
| that.
|
| The above is the pretty much the only way I could decide on how to answer
| your question as to which one-liner I consider my "best".
|
| --
| Rick (MVP - Excel)
|


From: Mike Williams on
"Scott M." <s-mar(a)nospam.nospam> wrote in message
news:u$KHy5eSKHA.1268(a)TK2MSFTNGP04.phx.gbl...

>> "Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote in message I've no doubt
>> that you have made numerous posts there. In fact I only recently had to
>> correct one of your answers in the VB.Net group in which you incorrectly
>> told the OP that there was no way to have an image as the background of a
>> VB.Net Textbox.
>
> It's really great that you've corrected something that I didn't say. Keep
> up the good work. And, practice your reading skills.

I wasn't paraphrasing you, Scotty. I was simply telling it like it is. The
OP asked:

"Does anyone have any sample code on how to draw a
semi transparent image as a watermark on a multiline textbox?"

.. . . and you replied:

"When you use Windows Forms controls, you must use them
as is. Meaning there is no way to do it."

I'll leave it up to the OP and to others here to decide for themselves what
they think you meant by that, and how helpful or unhelpful they think you
were to the OP, and whether or not they think you were correct.

Mike