473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Concatenation Revisited...

I took a look at the stringbuilder solutions discussed earlier today... and I have a question that is also tied to a result that is currently having me scratch my head. It looks like this:

Dim hexString1 as String
Dim hexString2 as String
Dim hexResult as String

hexString1 = Hex$(decValue1)
hexString2 = Hex$(decValue2)
hexResult = hexString1 & hexString2

main.output.additem(hexResult)

A couple things to note: hexString1 and hexString2 will always be used to represent one byte of data each. So the range of hexResult would be 0000h to FFFFh.

The code above seems to work in all instances, except in instances where the upper nibble of hexString2 is equal to Zero (ie: XX0Xh). When the value shows up as XX0Xh, the result appears as XX00h.

Is this normal? Any suggestions?
Nov 20 '05 #1
1 817
Jvangel,
The following gives what I believe you are asking for:

Dim decValue1 As Byte = 10
Dim decValue2 As Byte = 20
Dim hexResult As String = decValue1.ToString("X2") &
decValue2.ToString("X2")

The "problem" with Hex$ is it will only return a single hex digit for 0 to
15, where as ToString("X2") says you want Hex with 2 digits no matter what.

Hope this helps
Jay
"jvangel" <jv*****@discussions.microsoft.com> wrote in message
news:BB**********************************@microsof t.com...
I took a look at the stringbuilder solutions discussed earlier today... and I have a question that is also tied to a result that is currently having
me scratch my head. It looks like this:
Dim hexString1 as String
Dim hexString2 as String
Dim hexResult as String

hexString1 = Hex$(decValue1)
hexString2 = Hex$(decValue2)
hexResult = hexString1 & hexString2

main.output.additem(hexResult)

A couple things to note: hexString1 and hexString2 will always be used to represent one byte of data each. So the range of hexResult would be 0000h
to FFFFh.
The code above seems to work in all instances, except in instances where the upper nibble of hexString2 is equal to Zero (ie: XX0Xh). When the value
shows up as XX0Xh, the result appears as XX00h.
Is this normal? Any suggestions?

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Oliver Crow | last post by:
As a realtive python newb, but an old hack in general, I've been interested in the impact of having string objects (and other primitives) be immutable. It seems to me that string concatenation is...
5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
1
by: Fahd Khan | last post by:
Hi team! While troubleshooting a crash I had while using BitTorrent where the torrent's target file names didn't fall into the ascii range I was playing around in the interpreter and noticed this...
1
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of...
7
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so...
8
by: mrstephengross | last post by:
I'm using gcc 3.3.1 to compile the following code (below). I've written a macro to simplify writing operators. The macro uses the '##' operator to paste together 'operator' and the name of the...
9
by: Justin M. Keyes | last post by:
Hi, Please read carefully before assuming that this is the same old question about string concatenation in C#! It is well-known that the following concatenation produces multiple immutable...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
34
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
34
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.