DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 43

Thread: Converting Hex values to Decimal and Character

  1. #16
    Rick Rothstein Guest

    Re: Converting Hex values to Decimal and Character

    > > hence the reference to using
    > > "A" instead. The point I was trying to make was that the user of the

    > program can't *enter*
    > > &H41 without it being a String (VB's evil type conversions during

    > assignments to
    > > non-String variables notwithstanding). So, while Print Chr$(&H41) is

    > valid, it is not
    > > readily usable in that form when taking input from a user.

    >
    > I'll buy that, but I don't remember the question being limited to
    > user-enterable strings so you can't wiggle out taht easily oh great
    > kludgemaster <g>


    It wasn't, per se. However, since "A" is easier and more meaningful to use in code than
    Chr$("&H41"), I don't consider this an issue.


    > BTW, I would still maintain that Chr$(Clng("&H41")) is better than
    > Chr$("&H41") since it explicitly acknowledges that a conversion is being
    > done and eliminates any question about what rules VB should use for that
    > conversion.


    See my answer to your other post for comments that refer to this issue.


    Rick


  2. #17
    Bob Butler Guest

    Re: Converting Hex values to Decimal and Character


    "Rick Rothstein" <rick_newsgroup@email.com> wrote in message
    news:3c23d236$1@147.208.176.211...
    <cut>
    > LongVar = CLng(IntVar)


    For that one I would omit the CLng since it's Integer->Long Integer and
    there is no possibility of data corruption. I'd also omit an explicit
    conversion for Integer->single/double/currency mostly because the formats of
    each are well defined and there is only one possible conversion.

    For the othe examples you mentioned I'd always use CDate (if the string was
    YYYY-MM-DD or some other totally unambiguous format) or I'd pull apart the
    string, convert each section using CLng and then use DateSerial to put it
    together.

    I'm also a very lazy typist, but I've found that a little extra typing up
    front saves me a lot more later when something doesn't convert the way i
    expected it to! <g> YMMV




  3. #18
    Bob Butler Guest

    Re: Converting Hex values to Decimal and Character


    "Rick Rothstein" <rick_newsgroup@email.com> wrote in message
    news:3c23d33c$1@147.208.176.211...
    <cut>
    > It wasn't, per se. However, since "A" is easier and more meaningful to use

    in code than
    > Chr$("&H41"), I don't consider this an issue.


    When I saw the initial question dealing with a numeric value of &H41 I
    immediately thought of API calls and related structures where hex constants
    are common. i often have hex values in VB code and periodically want to
    display them as ascii strings while debugging. In that sort of code,
    Chr$(&H41) could easily be more meaningful. You are right that in more
    "normal" VB code the character would likely be more appropriate.




  4. #19
    Russ Guest

    Re: Converting Hex values to Decimal and Character


    >(Yeah, I know I'm in for a big problem if I ever move to VB.NET;
    >which, as things look now, I won't be doing.)
    >



    Rick,
    Not to open up another can of worms <g>. Just curious - why don't you want
    to go to .NET? I've read a couple of articles on it, but I wouldn't venture
    to say that I'm any authority on the subject. Based on what I've read though,
    it looks like many of the changes are things I've been wanting, like the
    fact that there will now be only one version of the STR(), TRIM(), MID(),
    etc. functions, rather than two. Also Dim arr(5) will now create exactly
    five elements [0..4] rather than 6 (I've always thought that was a bit ambiguous).
    And some of the new features like the control anchoring look pretty cool!
    What is it about it that you find compelling enough reason not to switch?

    -Russ



  5. #20
    Bob Butler Guest

    Re: Converting Hex values to Decimal and Character


    "Russ" <russell.thompson@adlink.com> wrote in message
    news:3c249f24$1@147.208.176.211...
    >
    > >(Yeah, I know I'm in for a big problem if I ever move to VB.NET;
    > >which, as things look now, I won't be doing.)

    > Rick,
    > Not to open up another can of worms <g>. Just curious - why don't you

    want
    > to go to .NET?


    Perhaps because it means rewriting just about every bit of code you have or
    having to work in both VB6 and VB.Net for an extended period?

    > I've read a couple of articles on it, but I wouldn't venture
    > to say that I'm any authority on the subject. Based on what I've read

    though,
    > it looks like many of the changes are things I've been wanting, like the
    > fact that there will now be only one version of the STR(), TRIM(), MID(),
    > etc. functions, rather than two.


    True, but that's hardly a selling point. You only have to use one of the
    VB6 versions now.

    > Also Dim arr(5) will now create exactly
    > five elements [0..4] rather than 6 (I've always thought that was a bit

    ambiguous).

    Not true. Dim arr(5) in VB.Net creates arr(0) through arr(5) [that was one
    minor concession that MS made towards maintaining compatibility with VB]. I
    don't see where either approach is ambiguous as long as you take the time to
    learn the syntax. Using either number-of-elements or upper-bound gets you
    teh same thing in the end. the nice thing about using upper-bound is that
    it leaves the door open for dim arr(lower-bound To upper-bound) which is,
    IMO, the best option since it leaves no doubt at all, even if you aren't
    sure of the syntax.

    > And some of the new features like the control anchoring look pretty cool!


    Yes, it has a lot of nice new features. Too bad they didn't make a version
    of VB that incorporates sthem instead of laying VB-like syntax over the top
    of C#.

    > What is it about it that you find compelling enough reason not to switch?


    No support for Windows 95 (and I still deal with a lot of Win95 clients)...
    a whole new set of runtime libraries to distribute (15-20MB IIRC)...
    complete redesign of every existing app if you want to really take advantage
    of new options... major rewriting just to get existing code to run at
    all...

    My issues with VB.Net are not so much whether or not it is a good tool but,
    since I can't reasonably port existing code the question becomes "is it the
    best option available?". If I've got to learn a new language and rewrite my
    apps then I'm going to look at C# as well as at other vendors to see what
    makes the most sense. Also, I have to overcome the distrust that MS may
    pull the rug out from under me again in a few years when their next big idea
    comes along. adoption of VB.Net is going to be slow, if at all.





  6. #21
    Joe \Nuke Me Xemu\ Foster Guest

    Re: Converting Hex values to Decimal and Character

    "Russ" <russell.thompson@adlink.com> wrote in message <news:3c249f24$1@147.208.176.211>...

    > >(Yeah, I know I'm in for a big problem if I ever move to VB.NET;
    > >which, as things look now, I won't be doing.)
    > >


    > Rick,
    > Not to open up another can of worms <g>. Just curious - why don't you want
    > to go to .NET? I've read a couple of articles on it, but I wouldn't venture
    > to say that I'm any authority on the subject. Based on what I've read though,
    > it looks like many of the changes are things I've been wanting, like the
    > fact that there will now be only one version of the STR(), TRIM(), MID(),
    > etc. functions, rather than two. Also Dim arr(5) will now create exactly
    > five elements [0..4] rather than 6


    Wrong, and didn't the C weenies squeal about that!

    > (I've always thought that was a bit ambiguous).


    Then always specify both bounds in your own code:

    dim arr(0 to 5) as object, arr2(1 to 5) as variant

    > And some of the new features like the control anchoring look pretty cool!
    > What is it about it that you find compelling enough reason not to switch?


    Ever use something like CHourglass or FileHandle to make your life a
    little easier? That's not where Microsoft wants you to go today!

    http://groups.google.com/groups?selm...%40tkmsftngp04

    http://devx.com/free/press/2000/102500.asp

    It's too bad, really, that VB.NOT takes away one of the most useful ways
    to use classes, the "resource acquisition is initialization" idiom:

    http://www.research.att.com/~bs/bs_faq2.html#finally

    http://devx.com/upload/free/features...p99/itsp99.asp

    Oh sure, you could attempt the same in VB.NyET and hope the GC gets around
    to cleaning up your resource management objects "quickly enough"... but,
    as we all know, the GC only launches a collection when it wants to or you
    remember to launch it yourself. So much for "ease of use" in B#, eh?

    --
    Joe Foster <mailto:jlfoster%40znet.com> On the cans? <http://www.xenu.net/>
    WARNING: I cannot be held responsible for the above They're coming to
    because my cats have apparently learned to type. take me away, ha ha!



  7. #22
    Russ Guest

    Re: Converting Hex values to Decimal and Character


    "Bob Butler" <butlerbob@earthlink.net> wrote:

    >> Also Dim arr(5) will now create exactly five elements [0..4] rather than

    6
    >
    >Not true. Dim arr(5) in VB.Net creates arr(0) through arr(5) [that was

    one
    >minor concession that MS made towards maintaining compatibility with VB].


    Guess I read some misinformation on this:
    http://www.vb-world.net/articles/vbdotnet2/index2.html


    >No support for Windows 95


    Really? That is something I wasn't aware of.


    > major rewriting just to get existing code to run at all...


    Heh Heh... That's not what MS wants you to think by the sound of this article.
    They make it sound like a walk in the park as long as you follow a few guidelines.

    http://msdn.microsoft.com/library/de...tovbdotnet.htm


    >Also, I have to overcome the distrust that MS may
    >pull the rug out from under me again in a few years when their next big

    idea
    >comes along.


    Yeah, they don't seem to mind doing that do they. <g>

    Guess I'll have to look into this a little more.

    Thanks Bob.
    -Russ



  8. #23
    Russ Guest

    Re: Converting Hex values to Decimal and Character


    "Joe \"Nuke Me Xemu\" Foster" <joe@bftsi0.UUCP> wrote:

    >>Also Dim arr(5) will now create exactly five elements [0..4] rather than

    6
    >
    >Wrong, and didn't the C weenies squeal about that!


    As I mentioned in my reply to Bob, this article states differently. But
    popular opinion seems to be that this article is incorrect so I'll go with
    that.
    http://www.vb-world.net/articles/vbdotnet2/index2.html


    >Ever use something like CHourglass or FileHandle to make your life a
    >little easier? That's not where Microsoft wants you to go today!
    >
    > http://groups.google.com/groups?selm...%40tkmsftngp04
    >
    > http://devx.com/free/press/2000/102500.asp
    >


    This sounds like a real problem. Many of my classes create a connection
    object at initialization and destroy it in the Terminate event. The article
    mentions that you could create and destroy the connection in every routine,
    but man that is alot of code to change!



    >It's too bad, really, that VB.NOT takes away one of the most useful ways
    >to use classes, the "resource acquisition is initialization" idiom:
    >
    > http://www.research.att.com/~bs/bs_faq2.html#finally
    >
    > http://devx.com/upload/free/features...p99/itsp99.asp
    >
    >Oh sure, you could attempt the same in VB.NyET and hope the GC gets around
    >to cleaning up your resource management objects "quickly enough"... but,
    >as we all know, the GC only launches a collection when it wants to or you
    >remember to launch it yourself. So much for "ease of use" in B#, eh?
    >


    Although I have never heard the term "resource acquisition is initialization"
    before, I have been using that idea in my classes for some time. I see what
    you are saying about this not working properly with NET's garbage collection.

    Thanks for the info Joe.
    -Russ.

  9. #24
    Rick Rothstein Guest

    Re: Converting Hex values to Decimal and Character

    And so, some of my reasons for not wanting to move to VB.NET were given by Bob and Joe.
    Other reasons can be found by searching GOOGLE for VB.NYET, VB.NOT or just maybe VB.NET
    <g>. Personally, when Microsoft finally "breaks" VB6 by Service Packing it away in WinXP,
    then I'll probably move to PowerBASIC. It looks quite strong to me and there appears to be
    graphical IDE available through 3rd party. But in looking at it, manually constructing the
    graphics doesn't look too bad except for the typing; and I'm willing to bet a subroutine
    library could be written to minimize that.

    Between the new language called VB.NET and forced registration of the XP line of products,
    Microsoft has lost a bundle on me. I used to be a "buy the upgrade no matter what" kind of
    guy. I haven't, and WON'T, move to WinXP, OfficeXP, FrontPageXP, PublisherXP, etc. And
    when Microsoft decides to kill off Win98SE to force everyone to XP, I'll probably look
    into LINUX as an alternative. My son's graduate school program uses LINUX and when he
    showed the graphical interface to me (can't remember the name he called it), I was hard
    pressed to tell the difference between it and Windows. On top of that, there is a program
    available that will let me install my VB6 as an application inside of the LINUX
    environment, so I won't lose out on any software I already own. And finally, my son says
    the system on his desk has been running for about a year now without being turned off or
    rebooted. Guess what? It hasn't crashed yet!

    I think Microsoft has made a serious error in judgment on these two (major) items. I find
    it hard to believe there are not more users just like me out there. Hey Microsoft... are
    you listening? There is still time to save this situation. Just bring out the VB7 that
    rumor has was nearly completed before the decision was made to force VB.NET down our
    throats. And if you dump that ridiculous registration scheme that you implemented to stop
    pirates (you do know your scheme has already been broken, don't you?), then perhaps I (and
    others?) will be willing to stay with you. If you force us to leave, I don't think you'll
    find it easy to win us back. But rest assured I will not beg you (or any other company)
    for permission to keep using the program I spent **my** money on just because I choose to
    upgrade or replace my system! (I'm not a fool; I am able to figure out what such lists
    would be worth to you in a few year when you sell these buying pattern list to various
    vendors so that they can spam me about their product at about the "right" time given my
    previous purchasing habits.)

    Rick


    "Russ" <russell.thompson@adlink.com> wrote in message news:3c2555dd@147.208.176.211...
    >
    > "Bob Butler" <butlerbob@earthlink.net> wrote:
    >
    > >> Also Dim arr(5) will now create exactly five elements [0..4] rather than

    > 6
    > >
    > >Not true. Dim arr(5) in VB.Net creates arr(0) through arr(5) [that was

    > one
    > >minor concession that MS made towards maintaining compatibility with VB].

    >
    > Guess I read some misinformation on this:
    > http://www.vb-world.net/articles/vbdotnet2/index2.html
    >
    >
    > >No support for Windows 95

    >
    > Really? That is something I wasn't aware of.
    >
    >
    > > major rewriting just to get existing code to run at all...

    >
    > Heh Heh... That's not what MS wants you to think by the sound of this article.
    > They make it sound like a walk in the park as long as you follow a few guidelines.
    >
    > http://msdn.microsoft.com/library/de...tovbdotnet.htm
    >
    >
    > >Also, I have to overcome the distrust that MS may
    > >pull the rug out from under me again in a few years when their next big

    > idea
    > >comes along.

    >
    > Yeah, they don't seem to mind doing that do they. <g>
    >
    > Guess I'll have to look into this a little more.
    >
    > Thanks Bob.
    > -Russ
    >
    >



  10. #25
    Bob Butler Guest

    Re: Converting Hex values to Decimal and Character


    "Russ" <russell.thompson@adlink.com> wrote in message
    news:3c2555dd@147.208.176.211...
    <cut>
    > >Not true. Dim arr(5) in VB.Net creates arr(0) through arr(5) [that was

    > one
    > >minor concession that MS made towards maintaining compatibility with VB].

    >
    > Guess I read some misinformation on this:
    > http://www.vb-world.net/articles/vbdotnet2/index2.html


    In VB.Net Beta 1 the line "Dim a(5)" created a(0) to a(4) but that was
    changed in beta 2 to conform to VB6 semantics. It was one of a few changes
    made to help ease transition and maintain compatibility. Unfortunately,
    IMO, MS did not go far enough and has ended up with a language that annoys
    just about everybody for one reason or another.<g>

    There are vb.dotnet.technical and vb.dotnet.discussion groups on the devx
    server and microsoft.public.dotnet.* groups at msnews.microsoft.com where
    these topics are more appropriate.



  11. #26
    Russ Guest

    Re: Converting Hex values to Decimal and Character


    "Rick Rothstein" <rick_newsgroup@email.com> wrote:
    >And so, some of my reasons for not wanting to move to VB.NET were given

    by Bob and Joe.
    >Other reasons can be found by searching GOOGLE for VB.NYET, VB.NOT or just

    maybe VB.NET
    ><g>. Personally, when Microsoft finally "breaks" VB6 by Service Packing

    it away in WinXP,
    >then I'll probably move to PowerBASIC. It looks quite strong to me and there

    appears
    >to be
    >graphical IDE available through 3rd party. But in looking at it, manually

    constructing
    >the
    >graphics doesn't look too bad except for the typing; and I'm willing to

    bet a subroutine
    >library could be written to minimize that.
    >
    >Between the new language called VB.NET and forced registration of the XP

    line of products,
    >Microsoft has lost a bundle on me. I used to be a "buy the upgrade no matter

    what" kind
    >of
    >guy. I haven't, and WON'T, move to WinXP, OfficeXP, FrontPageXP, PublisherXP,

    etc. And
    >when Microsoft decides to kill off Win98SE to force everyone to XP, I'll

    probably look
    >into LINUX as an alternative. My son's graduate school program uses LINUX

    and when he
    >showed the graphical interface to me (can't remember the name he called

    it), I was hard
    >pressed to tell the difference between it and Windows. On top of that, there

    is a program
    >available that will let me install my VB6 as an application inside of the

    LINUX
    >environment, so I won't lose out on any software I already own. And finally,

    my son
    >says
    >the system on his desk has been running for about a year now without being

    turned off
    >or
    >rebooted. Guess what? It hasn't crashed yet!
    >
    >I think Microsoft has made a serious error in judgment on these two (major)

    items. I
    >find
    >it hard to believe there are not more users just like me out there. Hey

    Microsoft...
    >are
    >you listening? There is still time to save this situation. Just bring out

    the VB7 that
    >rumor has was nearly completed before the decision was made to force VB.NET

    down our
    >throats. And if you dump that ridiculous registration scheme that you implemented

    to
    >stop
    >pirates (you do know your scheme has already been broken, don't you?), then

    perhaps
    >I (and
    >others?) will be willing to stay with you. If you force us to leave, I don't

    think you'll
    >find it easy to win us back. But rest assured I will not beg you (or any

    other company)
    >for permission to keep using the program I spent **my** money on just because

    I choose
    >to
    >upgrade or replace my system! (I'm not a fool; I am able to figure out what

    such lists
    >would be worth to you in a few year when you sell these buying pattern list

    to various
    >vendors so that they can spam me about their product at about the "right"

    time given
    >my
    >previous purchasing habits.)
    >
    >Rick
    >
    >


    Rick,
    Heh Heh - Well, as I said, I didn't mean to open up a whole new can of worms,
    but I guess I did anyway <g>. I hear every word you are saying and I'm right
    there with you. I won't be buying any XP products either - not if I have
    to deal with product registration.

    I appreciate everyone's comments and apologize for interupting your original
    conversation <g>.

    -Russ.



  12. #27
    Patrick Troughton Guest

    Re: Converting Hex values to Decimal and Character


    >It's too bad, really, that VB.NOT takes away one of the most useful ways
    >to use classes, the "resource acquisition is initialization" idiom:


    Wow, that's quite a stretch. I have probably 20 or 30 books on VB and that's
    the first time I heard that one. Most people would say that biggest advantages
    of classes are code reuse, encapsolation, polymorphism, etc. but you think
    it's "resource acquisition is initialization". Hehe. I see the links you
    provide as "evidence" are C++ articles. Still grasping for straws, eh Joe?


    /Pat


  13. #28
    Patrick Troughton Guest

    Re: Converting Hex values to Decimal and Character


    "Russ" <russell.thompson@adlink.com> wrote:
    >
    >>No support for Windows 95

    >
    >Really? That is something I wasn't aware of.


    This is true. But this is not just a .NET issue. Windows 95 is almost seven
    years old now. If I'm not mistaken, Microsoft is dropping all support for
    Windows 95 very early next year.

    /Pat

  14. #29
    Patrick Troughton Guest

    Re: Converting Hex values to Decimal and Character


    "Joe \"Nuke Me Xemu\" Foster" <joe@bftsi0.UUCP> wrote:
    >"Patrick Troughton" <Patrick@Troughton.com> wrote in message <news:3c265851@147.208.176.211>...
    >
    >
    >I'd gotten good encapsulation and code re-use even before classes, using
    >plain old modules.


    I agree with you on that.

    > As even you should be
    >able to see, assuming you pull your head out one of these days, I said
    >that the "resource acquisition is initialization" idiom is *one* of the
    >most useful ways to use classes, not *the* most useful.


    You need some work on your reading comprehension skills. Go back and re-read
    my post. If there's something you don't understand, *ask*. That would be
    a much better idea than putting your foot in your mouth by accusing me of
    saying something I didn't say.

    >Anyway, not all
    >of the cites were C++ articles -- you "must have missed" Phil Weber's own
    >CHourglass class!


    Again, your reading comprehension skills have failed you. Where in Phil's
    article does he say that "resource acquisition is initialization" is one
    of the most useful ways to use classes?

    In fact, please tell everyone the *exact* line number where he says that
    "resource acquisition is initialization" is one of the most useful ways to
    use classes. We would love to see where he says that. Don't worry - take
    all the time you need to find the quote. We'll wait....

    >Now FOAD.NET, moron.


    Ah, the personal insult. You sure showed me. Boy, if that doesn't prove to
    everyone you're right, I don't know what will!

    /Pat


  15. #30
    Bob Butler Guest

    Re: Converting Hex values to Decimal and Character


    "Patrick Troughton" <Patrick@Troughton.com> wrote in message
    news:3c265d7d@147.208.176.211...
    >
    > "Russ" <russell.thompson@adlink.com> wrote:
    > >
    > >>No support for Windows 95

    > >
    > >Really? That is something I wasn't aware of.

    >
    > This is true. But this is not just a .NET issue. Windows 95 is almost

    seven
    > years old now. If I'm not mistaken, Microsoft is dropping all support for
    > Windows 95 very early next year.


    That doesn't help the fact that a large number of systems are still running
    it. Before a dotnet app can be deployed those systems must all be updated,
    which may require hardware updates as well in some cases. That makes the
    cost of client-side dotnet deployment very large.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center