Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB script for Hexadecimal usage

Posted on 2008-10-01
8
Medium Priority
?
380 Views
Last Modified: 2012-06-21
Hi,

We have a hexadecimal like  0C0BA715B2223D47A8CACA87BE5D9679 . We want to use that in Vb script. We are not able to use that because it was taking only 8 bit values. So Could please tell us how can we use this kind of long hexadecimals in Vb script for assigning and addition.

Thanks in advance.
0
Comment
Question by:ADP india
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22614889
According to
http://support.microsoft.com/kb/279115

Use
 MsgBox CLng("&h" & hex_value)

0
 

Author Comment

by:ADP india
ID: 22615432
COULD YOU PLEASE TELL ME HOW TO ASSIGN 32 DIGIT HEXADECIMAL VALUE ( LIKE 0C0BA715B2223D47A8CACA87BE5D9679 ) TO A VARIABLE.

I HAVE TRIED  THIS WAY
DIM X= &h123AB344
ITS EXACTLY TAKING 8 DIGITS ELSE IT IS SAYING SYNTAX ERROR
PLEASE LET ME KNOW HOW TO PROCEED FURTHER...
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22615523
Try the modified solution from here: http://www.experts-exchange.com/Q_21716456.html
HexVal="0C0BA715B2223D47A8CACA87BE5D9679"
 
wscript.echo HexToDec (HexVal)
 
Function HexToDec(HexNum)
    Dim x
    Dim TempValue
    Dim Digit
    Dim DecValue
 
    If UCase(Left(HexNum, 2)) = "&H" Then HexNum = Right(HexNum, Len(HexNum) - 2)
 
    For x = Len(HexNum) To 1 Step -1
        Digit = Mid(HexNum, x, 1)
        If UCase(Digit) = "A" Then
                TempValue = 10
        ElseIf UCase(Digit) = "B" Then
                TempValue = 11
        ElseIf UCase(Digit) = "C" Then
                TempValue = 12
        ElseIf UCase(Digit) = "D" Then
                TempValue = 13
        ElseIf UCase(Digit) = "E" Then
                TempValue = 14
        ElseIf UCase(Digit) = "F" Then
                TempValue = 15
        ElseIf UCase(Digit) >= "0" And UCase(Digit) <= "9" Then
                TempValue = Digit
      Else
                wscript.echo "Error in Hex string! (" & HexNum & ")"
                Exit Function
        End If
 
        DecValue = DecValue + TempValue * 16 ^ (Len(HexNum) - x)
    Next
 
    HexToDec = DecValue
End Function

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:MoreHeroic
ID: 22615731
0
 

Author Comment

by:ADP india
ID: 22622087
I believe this converts hexadecimal value to decimal. but i directly want to increment the hex value...is there any possibility as such....if so please let us know.

Thanks for the response.
0
 

Author Comment

by:ADP india
ID: 22622108
Also how do i assign this 32digit hex value to a variable..bcoz by default it is taking only 8digits and also is there any static declaration kind of thing in vb like in "c" so that it retains latest value every time i run a script.

For ex: if today a variable contains 0 i run the  script and after increments and all the  latest value is 5
next time when i run the same script i should continue from 5 and not 0
0
 
LVL 10

Accepted Solution

by:
MoreHeroic earned 1500 total points
ID: 22624576
Here you go, large hex string addition where you keep the HEX values in strings:

http://blog.benfinnigan.com/2008/10/vbscript-adding-large-hex-strings.html
0
 
LVL 10

Expert Comment

by:MoreHeroic
ID: 22624591
To answer your question about keeping the variable static it wouldn't work between runs unless you stored it off someplace because once the vbscript has completed it is removed from memory.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question