Selasa, 15 Januari 2013

[ExcelVBA] Re: convert text to numbers with For Each xCell

 


--- Paul Schreiner wrote, in part:
>...
> Actually, there are many types of "strings" in programming.
> binary strings
> hexadecimal strings
> text strings
> character strings
> and yes, "numeric" strings

Paul,
A peripheral comment/question. Out of curiosity, I want to clarify the connection between the terminology you use here and the underlying concept. I know what these things could mean to me, but wonder if it is what you mean.

I would describe a *string* as something that the computer stores internally as ASCII codes; or at least if asked to display this "thing" to you in its normal manner, the computer will display the _character(s)_ represented by those ASCII codes rather than some other representation of the binary bits. [space, LF CR, TAB etc. accepted as *characters*)

In other words:
Dim X As String
X = "A"
Print A
Then, I see the character 'A' on the screen. However, internally the computer actually has the bit pattern 01000001, which has other representations, namely: a decimal `equivalent' of 65, or a hex `equivalent' of 41. However these `equivalents' are virtual since `A' is not a number at all (in human terms).

This is related to that old (human readable) joke: "There are 10 kinds of people in the world; those who understand Binary and those who don't." What representation "10" is displayed in is the secret. In this case, it is a mixed base kinda' thing. We expect decimal representation, but that's not what was `sent'.

SO:
Is this what you mean ?
> binary strings > "1011001" (Quotes in the normal programming sense)
> hexadecimal strings > "&H7F4B"
> and yes, "numeric" strings > "123"
In other words, having the computer store this stuff as the ASCII codes?

On the other hand:
I have had to send what amounts to binary (also represented on my screen as Hex) data out a serial port and used a technique that might be called binary, or hex strings:

(I simplify for demonstration)
Dim Command As String
Command = CHR$(&H2F) & CHAR(&H7B)
[ Then, I stuff the variable Command out the serial port.]

Now, I don't look at this output, but rather feed it to some external device that understands the bit sequence 00101111, 01111011. That is surely binary data, but I *might* be inclined to call _that_ a "binary string", or less likely "Hex string".
Which concept are you referring to with "binary/hex" string?

Then, the big question that tweeked my curiosity...

How do you differentiate between "text" and "character" strings?

Like this?
> text strings > "Now it the time...", or understandable text.
> character strings > "afF1%,/ _)(", or any (Printable, and/or non printable) ASCII chars
??
--
Perhaps too curious for my own good, but TV is booring,
Steve N.

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (16)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar