2011-07-01 9 views
6

Jak przekonwertować wartość szesnastkową na wartość dziesiętną w VB6?Konwertuj wartość szesnastkową na wartość dziesiętną w VB6

Próbuję po prostu sprawdzić, czy to działa:

Dim hexVal as string 
hexVal = "#7B19AB" 
clng("&H" & hexVal) 

Jednak Dostaję "Rodzaj niedopasowanie" błąd.

+2

Ahh, masz na myśli "przekonwertuj ciąg szesnastkowy na binarny Long". Nie ma w ogóle udziału "dziesiętny". – Bob77

Odpowiedz

9

Pozbyć się znakiem #

Dim hexVal as string 
hexVal = "7B19AB" 
clng("&H" & hexVal) 
4

Pozbądź się znaku liczby (#) w ciągu znaków hexVal.

0

ten powinien zrobić to

Dim hexVal as String 
hexVal = "#7B19AB" 
Dim intVal as Integer 
intVal = Val("&H" & Replace(hexVal, "#", "")) 
2

spróbować:

value=CDbl("&H" & HexValue) 

lub

value=CInt("&H" & HexValue) 'but range +- 32,768 
+1

Dziękujemy za przesłanie tej odpowiedzi, ale jest ona duplikatem innych już opublikowanych i zaakceptowanych. Jeśli chcesz ulepszyć istniejący anser, edytuj go, a zostanie on sprawdzony przez innych w społeczności. – Deanna

1

spróbować go >>>>>> Print Hex (ASC (Text1.Text))

0
Dim uzunluk as Integer 

On Error Resume Next 
uzunluk = Len(Text1.Text) 
For i = 0 To uzunluk 
    Text1.SelStart = i 
    Text1.SelLength = 1 
    Print Hex(Asc(Text1.SelText)) 
Next i 
0

< < < < Dim hexVal As String Dim str As String Dim uzunluk As Integer On Error Resume Next hexVal = "# 7B19AB" str = Zamień (hexVal, "#", "") Text1.Text = str uzunluk = Len (Text1.Text) For i = 0 To uzunluk Text1.SelStart = i Text1.SelLength = 1 Print Hex (Asc (Text1.SelText)) Dalej i

Powiązane problemy