Cool way to have a Hello Message. (Remember Calculus?)

Was this of interest to you?

  • YES, this is WAY cool!

    Votes: 2 20.0%
  • Don't hate it, Don't love it.

    Votes: 1 10.0%
  • NO, this is a waste of time!

    Votes: 7 70.0%

  • Total voters
    10

Cosmos75

Registered User.
Local time
Today, 03:24
Joined
Apr 22, 2002
Messages
1,280
Try this for a cool way to have a messagebox greeting. Not my code, see bottom to find link where I found it.

Sub HowDidHeDoThat()
For x = 0 To 5
x1 = x1 & Chr(x * (x * (x * (x * (-0.75 * x + 7.2917) _
- 22.5) + 16.708) + 28.25) + 72)
Next x
For x = 0 To 6
x2 = x2 & Chr(x * (x * (x * (x * (x * (0.425 * x - 6.8667) _
+ 40.833) - 109.58) + 122.24) - 23.05) + 87)
Next x
MsgBox x1 & x2
End Sub


Don't read on if you don't want to know how this works.


Bob Umlas supplied the code, but the originator is unknown.


Still want to know how this works?


OK, I thought of writing my own explanations but someone has a better one. Here's how Damon Ostrander (You can find him posting on MrExcel.com) explained it. More elegantly than I could have done!


"Any text string can be represented by a sequence of numbers, one for each character, that represent the ASCII character codes of the characters. For example, the letter H is 72 in decimal, which is why the VBA function Chr(72) returns an "H". The two equations in this routine represent factored forms of two power series polynomials. For the case of the variable x1 in this code, these polynomials have been set up to represent a curve that passes exactly through the ASCII codes of all the characters in "Hello ". So this curve passes exactly through the points:

X Y
0 72 H
1 101 e
2 108 l
3 108 l
4 111 o
5 32 (space)

This represents a 5th-order polynomial, and requires solving for the 6 coefficients. The required order of the polynomial is always the number of points it must pass through minus 1. I wouldn't want to have to do this by hand, but this can be done by Excel using the curve-fitting capability. Breaking the string into two substrings enabled solving a 5th- and 6th-order polynomial rather than a single 12th-order polynomial, which is much harder.

Also, the curve doesn't have to EXACTLY pass through these points since they are integers. It must just exceed them by no more than one so that when they are truncated to the nearest integer they have the correct values."


Hope someone else finds this interesting!
 
Last edited:
Well, golly gee--

Was about to respond with a '...dust off your pocket protectors, boys and girls' response when I realized that would be grossly unfair if I hadn't tried it.

Result: You haven't defined your variables, thus it doesn't work.

Could you please help?:o
 
Some people (namely Messers Umlas and Ostranders) have way too much time on their hands. How long did it take to do that??? And with Polynomials as well!

*shuddering at the thought of polynomials*
 
It does work!

Here's an Excel 2000 file. Click the button and the message with show up.

:D
 

Attachments

Been awhile since I've looked at this, was wondering if anybody had anything else that is in the vein as this?
(Ok, so I admit it. I am somewhat of a nerd.):p
 
Yes, you heard me.
:mad:

I play tennis, play the guitar and have a girlfriend (non-virtual and not internet-based). I figure that only makes me somewhat of a nerd.
:p

Maybe closer to a cool nerd.
:D
 

Users who are viewing this thread

Back
Top Bottom