Problème de convertion (asc, hex, &h) sous vb.net

Résolu
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 - 16 déc. 2010 à 23:32
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 - 23 déc. 2010 à 01:35
Bonsoir,

je cherche a convertir la lettre D afin d'obtenir la valeur 68.
Par quoi est remplacé le &h du VB6 ?
Par quoi est remplacé le Asc du VB6 ?

Voici mon code:
Dim rt As Byte
Dim rtVal As Integer
rt Conversion.Hex(Asc("D")) 'rt 44
rtVal = ????(rt)
'rtVal = 68 ^^
A voir également:

7 réponses

Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
23 déc. 2010 à 01:26
Je partage mes quelques progrès en la matière ^^

    Class StringHex
        Shared Property rtInteger As Int32
        Shared Property rtHexadecimal As String
        Shared Function ConvertEx(ByVal value As Object) As Object
            Try
                Dim rt As Object
                Select Case Convert.GetTypeCode(value)
                    Case TypeCode.String 'PSEUDO HEX to INT32
                        rtHexadecimal = value.ToString
                        rt = "&h" & CType(value, String)
                        rt = CByte(rt)
                        rtInteger = CType(rt, Int32)
                    Case TypeCode.Int32 'INT32 to HEX
                        rtInteger = CType(value, Int32)
                        rt = String.Format("{0:X}", value).ToUpper
                        rtHexadecimal = rt.ToString
                    Case Else
                        rt = Nothing
                End Select
                Return rt

            Catch ex As Exception
                MessageBox.Show(ex.Message, _
                                "Erreur Hexadecimal()", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
            Return Nothing
        End Function
    End Class
    

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim HEX_OBJ(1) As Object
        Dim HEX_BYTE(1) As Byte
        Dim HEX_INT(1) As Integer
        Dim ResultatXOR As Integer
        Dim InfoHex As String

        'Demonstration de conversion HEX vers Object, byte et integer
        'ID 0
        HEX_OBJ(0) = StringHex.ConvertEx("6B")
        HEX_BYTE(0) = CByte(StringHex.ConvertEx("6B"))
        HEX_INT(0) = CInt(StringHex.ConvertEx("6B"))
        'ID 1
        HEX_OBJ(1) = StringHex.ConvertEx("31")
        HEX_BYTE(1) = CByte(StringHex.ConvertEx("31"))
        HEX_INT(1) = CInt(StringHex.ConvertEx("31"))

        'L'hexa sert d'information visuelle , rien de plus, nous allons donc travailler sur du Integer
        ResultatXOR = HEX_INT(0) Xor HEX_INT(1)

        'Convertion du int en hex
        InfoHex = CStr(StringHex.ConvertEx(ResultatXOR))

        'Convertion uniquement a la sortie
        'Hexadecimal sert qu'a titre d'information de lecture
        MessageBox.Show("ENTRAINEMENT: " & StringHex.rtInteger & _
        Environment.NewLine & _
        "INDICATIF: " & InfoHex)
    End Sub
3
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
17 déc. 2010 à 00:05
Mégalol

Dim tDec As Decimal
tDec = CType(44, Decimal)
'tDec = 44D
0
NSUADI Messages postés 540 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 1 février 2013 2
17 déc. 2010 à 00:34
eh ben:
Convert.ToInt32("D"c)

devrait faire l'affaire..
Ce qui compte,ce n'est pas ce qu'on a mais plutôt ce que l'on fait avec ce qu'on a...

Visual Basic .Net is the best
and vb6.0
0
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
17 déc. 2010 à 00:49
merci ^^
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
17 déc. 2010 à 02:10
Qui veut essayer de faire: 6B xor 31 ^^
Sur ma calculatrice sa fait 5A
Dans .net il me dis que 6B n'est pas un byte !
0
cs_casy Messages postés 7741 Date d'inscription mercredi 1 septembre 2004 Statut Membre Dernière intervention 24 septembre 2014 40
17 déc. 2010 à 09:26
Tu veux probablement faire : &h6B xor &h31



[i][b]---- Sevyc64 (alias Casy) ----
[hr]# LE PARTAGE EST NOTRE FORCE #/b/i
0
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
23 déc. 2010 à 01:35
Pour donner des idées avec ID 0 et ID 1 ^^

8 bytes :)
ID 0 à ID 7 = AH ou AL

16 bytes :)
ID 0 à ID 15 = AX

32 bytes :)
ID 0 à ID 29 = EAX
0
Rejoignez-nous