2011-07-01 33 views
6

Come posso convertire un valore esadecimale in un valore decimale in VB6?Convertire il valore esadecimale in un valore decimale in VB6

sto cercando solo per vedere se questo funziona:

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

Tuttavia, sto diventando "tipo non corrispondente" errore.

+2

Ah, intendete "convertire una stringa esadecimale in una lunghezza binaria". Non è previsto alcun "decimale". – Bob77

risposta

9

Sbarazzarsi della segno #

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

Sbarazzarsi del segno di numero (#) nella stringa hexVal.

0

Questo dovrebbe farlo

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

Prova:

value=CDbl("&H" & HexValue) 

o

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

Grazie per aver postato la risposta, ma è un duplicato di altre già pubblicate e accettate. Se vuoi migliorare un anser esistente, modificalo e verrà esaminato da altri nella comunità. – Deanna

1

prova ad esso >>>>>> Stampa 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 come numero intero On Error Resume Next HEXVAL = "# 7B19AB" str = Sostituisci (hexVal, "#", "") Text1.Text = str uzunluk = Len (Text1.Text) Per i = 0 Per uzunluk Text1.SelStart = i Text1.SelLength = 1 Stampa Hex (Asc (Text1.SelText)) Avanti i

Problemi correlati