IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

Limite de caractères ? oO


Sujet :

VB 6 et antérieur

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de Ramdoulou
    Profil pro
    Étudiant
    Inscrit en
    Novembre 2006
    Messages
    286
    Détails du profil
    Informations personnelles :
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2006
    Messages : 286
    Par défaut Limite de caractères ? oO
    Bonjour à tous.
    Pour m'entrainer je fais un petit Convertisseur de caractère en Code Ascii ou Héxadecimal.

    Mais je viens de m'apercevoir que Visual Basic 6 avait une limite de caractères de code oO :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    'Caractère !
    If txt.Text = "!" And o1 = True Then
    txt1.Text = "33"
    ElseIf txt.Text = "!" And o2 = True Then
    txt1.Text = "21"
    End If
     
    'Caractère #
    If txt.Text = "#" And o1 = True Then
    txt1.Text = "35"
    ElseIf txt.Text = "#" And o2 = True Then
    txt1.Text = "23"
    End If
     
    'Caractère $
    If txt.Text = "$" And o1 = True Then
    txt1.Text = "36"
    ElseIf txt.Text = "$" And o2 = True Then
    txt1.Text = "24"
    End If
     
    'Caractère %
    If txt.Text = "%" And o1 = True Then
    txt1.Text = "37"
    ElseIf txt.Text = "%" And o2 = True Then
    txt1.Text = "25"
    End If
     
    'Caractère &
    If txt.Text = "&" And o1 = True Then
    txt1.Text = "38"
    ElseIf txt.Text = "&" And o2 = True Then
    txt1.Text = "26"
    End If
     
    'Caractère '
    If txt.Text = "'" And o1 = True Then
    txt1.Text = "39"
    ElseIf txt.Text = "'" And o2 = True Then
    txt1.Text = "27"
    End If
     
    'Caractère (
    If txt.Text = "(" And o1 = True Then
    txt1.Text = "40"
    ElseIf txt.Text = "(" And o2 = True Then
    txt1.Text = "28"
    End If
     
    'Caractère )
    If txt.Text = ")" And o1 = True Then
    txt1.Text = "41"
    ElseIf txt.Text = ")" And o2 = True Then
    txt1.Text = "29"
    End If
     
    'Caractère *
    If txt.Text = "*" And o1 = True Then
    txt1.Text = "42"
    ElseIf txt.Text = "*" And o2 = True Then
    txt1.Text = "2A"
    End If
     
    'Caractère +
    If txt.Text = "+" And o1 = True Then
    txt1.Text = "43"
    ElseIf txt.Text = "+" And o2 = True Then
    txt1.Text = "2B"
    End If
     
    'Caractère ,
    If txt.Text = "," And o1 = True Then
    txt1.Text = "44"
    ElseIf txt.Text = "," And o2 = True Then
    txt1.Text = "2C"
    End If
     
    'Caractère -
    If txt.Text = "-" And o1 = True Then
    txt1.Text = "45"
    ElseIf txt.Text = "-" And o2 = True Then
    txt1.Text = "2D"
    End If
     
    'Caractère .
    If txt.Text = "." And o1 = True Then
    txt1.Text = "46"
    ElseIf txt.Text = "." And o2 = True Then
    txt1.Text = "2E"
    End If
     
    'Caractère /
    If txt.Text = "/" And o1 = True Then
    txt1.Text = "47"
    ElseIf txt.Text = "/" And o2 = True Then
    txt1.Text = "2F"
    End If
     
    'Caractère 0
    If txt.Text = "0" And o1 = True Then
    txt1.Text = "48"
    ElseIf txt.Text = "0" And o2 = True Then
    txt1.Text = "30"
    End If
     
    'Caractère 1
    If txt.Text = "1" And o1 = True Then
    txt1.Text = "49"
    ElseIf txt.Text = "1" And o2 = True Then
    txt1.Text = "31"
    End If
     
    'Caractère 2
    If txt.Text = "2" And o1 = True Then
    txt1.Text = "50"
    ElseIf txt.Text = "2" And o2 = True Then
    txt1.Text = "32"
    End If
     
    'Caractère 3
    If txt.Text = "3" And o1 = True Then
    txt1.Text = "51"
    ElseIf txt.Text = "3" And o2 = True Then
    txt1.Text = "33"
    End If
     
    'Caractère 4
    If txt.Text = "4" And o1 = True Then
    txt1.Text = "52"
    ElseIf txt.Text = "4" And o2 = True Then
    txt1.Text = "34"
    End If
     
    'Caractère 5
    If txt.Text = "5" And o1 = True Then
    txt1.Text = "53"
    ElseIf txt.Text = "5" And o2 = True Then
    txt1.Text = "35"
    End If
     
    'Caractère 6
    If txt.Text = "6" And o1 = True Then
    txt1.Text = "54"
    ElseIf txt.Text = "6" And o2 = True Then
    txt1.Text = "36"
    End If
     
    'Caractère 7
    If txt.Text = "7" And o1 = True Then
    txt1.Text = "55"
    ElseIf txt.Text = "7" And o2 = True Then
    txt1.Text = "37"
    End If
     
    'Caractère 8
    If txt.Text = "8" And o1 = True Then
    txt1.Text = "56"
    ElseIf txt.Text = "8" And o2 = True Then
    txt1.Text = "38"
    End If
     
    'Caractère 9
    If txt.Text = "9" And o1 = True Then
    txt1.Text = "57"
    ElseIf txt.Text = "9" And o2 = True Then
    txt1.Text = "39"
    End If
     
    'Caractère :
    If txt.Text = ":" And o1 = True Then
    txt1.Text = "58"
    ElseIf txt.Text = ":" And o2 = True Then
    txt1.Text = "3A"
    End If
     
    'Caractère ;
    If txt.Text = ";" And o1 = True Then
    txt1.Text = "59"
    ElseIf txt.Text = ";" And o2 = True Then
    txt1.Text = "3B"
    End If
     
    'Caractère <
    If txt.Text = "<" And o1 = True Then
    txt1.Text = "60"
    ElseIf txt.Text = "<" And o2 = True Then
    txt1.Text = "3C"
    End If
     
    'Caractère =
    If txt.Text = "=" And o1 = True Then
    txt1.Text = "61"
    ElseIf txt.Text = "=" And o2 = True Then
    txt1.Text = "3D"
    End If
     
    'Caractère >
    If txt.Text = ">" And o1 = True Then
    txt1.Text = "62"
    ElseIf txt.Text = ">" And o2 = True Then
    txt1.Text = "3E"
    End If
     
    'Caractère ?
    If txt.Text = "?" And o1 = True Then
    txt1.Text = "63"
    ElseIf txt.Text = "?" And o2 = True Then
    txt1.Text = "3F"
    End If
     
    'Caractère @
    If txt.Text = "@" And o1 = True Then
    txt1.Text = "64"
    ElseIf txt.Text = "@" And o2 = True Then
    txt1.Text = "40"
    End If
     
    'Caractère A
    If txt.Text = "A" And o1 = True Then
    txt1.Text = "65"
    ElseIf txt.Text = "A" And o2 = True Then
    txt1.Text = "41"
    End If
     
    'Caractère B
    If txt.Text = "B" And o1 = True Then
    txt1.Text = "66"
    ElseIf txt.Text = "B" And o2 = True Then
    txt1.Text = "42"
    End If
     
    'Caractère C
    If txt.Text = "C" And o1 = True Then
    txt1.Text = "67"
    ElseIf txt.Text = "C" And o2 = True Then
    txt1.Text = "43"
    Voilà, apres cela je ne peux plus enregistrer de caractères dans ce CommandButton...

    Est-ce possible d'augmenter la capacité de caractères dans le code ?
    Merci et bonne journée

  2. #2
    Membre émérite Avatar de avigeilpro
    Homme Profil pro
    Ambulancier
    Inscrit en
    Janvier 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Creuse (Limousin)

    Informations professionnelles :
    Activité : Ambulancier
    Secteur : Transports

    Informations forums :
    Inscription : Janvier 2004
    Messages : 880
    Par défaut
    Je n'ai pas de réponse à ta question mais pourquoi n'utilise-tu pas la fonction Asc ??
    Et je n'ai jamais vu de limite de taille de code, étant donné qu'il sagit simplement d'un editeur de texte dans lequel VB verifie la syntaxe. C'est assez curieux.
    La connaissance seule ne suffit pas. La vraie compréhension vient de la mise en expérience.
    Règles|FAQ|Tuto

  3. #3
    Membre éclairé Avatar de Ramdoulou
    Profil pro
    Étudiant
    Inscrit en
    Novembre 2006
    Messages
    286
    Détails du profil
    Informations personnelles :
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2006
    Messages : 286
    Par défaut
    Apres le Caractère C, je ne peux plus ajouter de conditions.
    Par contre je peux modifier les codes déjà inscrits, ça ya pas de problemes.

  4. #4
    Membre éclairé Avatar de Ramdoulou
    Profil pro
    Étudiant
    Inscrit en
    Novembre 2006
    Messages
    286
    Détails du profil
    Informations personnelles :
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2006
    Messages : 286
    Par défaut
    En faite, j'ai l'impression que ca vient des caractères oO
    Bon, donc mon convertisseur se présente comme cela :



    Dexu options nommées o1 et o2
    De RichtextBox nommée txt et txt1
    Et un CommandButton nommé par défault, Command1.

    Donc sur le bouton j'ai inscrit le code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    'Caractère A
    If txt.Text = "A" And o1 = True Then
    txt1.Text = "65"
    ElseIf txt.Text = "A" And o2 = True Then
    txt1.Text = "41"
    End If
     
    'Caractère B
    If txt.Text = "B" And o1 = True Then
    txt1.Text = "66"
    ElseIf txt.Text = "B" And o2 = True Then
    txt1.Text = "42"
    End If
     
    'Caractère C
    If txt.Text = "C" And o1 = True Then
    txt1.Text = "67"
    ElseIf txt.Text = "C" And o2 = True Then
    txt1.Text = "43"
     
    'Caractère D
    If txt.Text = "D" And o1 = True Then
    txt1.Text = "68"
    ElseIf txt.Text = "D" And o2 = True Then
    txt1.Text = "44"
    End If
     
    'Caractère E
     
    If txt.Text = "E" And o1 = True Then
    txt1.Text = "69"
    ElseIf txt.Text = "E" And o2 = True Then
    txt1.Text = "45"
    End If
     
    'Caractère F
    If txt.Text = "F" And o1 = True Then
    txt1.Text = "70"
    ElseIf txt.Text = "F" And o2 = True Then
    txt1.Text = "46"
    End If
     
    'Caractère G
    If txt.Text = "G" And o1 = True Then
    txt1.Text = "71"
    ElseIf txt.Text = "G" And o2 = True Then
    txt1.Text = "47"
    End If
     
    'Caractère H
    If txt.Text = "H" And o1 = True Then
    txt1.Text = "72"
    ElseIf txt.Text = "H" And o2 = True Then
    txt1.Text = "48"
    End If
     
    'Caractère I
    If txt.Text = "I" And o1 = True Then
    txt1.Text = "73"
    ElseIf txt.Text = "I" And o2 = True Then
    txt1.Text = "49"
    End If
     
    'Caractère J
    If txt.Text = "J" And o1 = True Then
    txt1.Text = "74"
    ElseIf txt.Text = "J" And o2 = True Then
    txt1.Text = "4A"
    End If
     
    'Caractère K
    If txt.Text = "K" And o1 = True Then
    txt1.Text = "75"
    ElseIf txt.Text = "K" And o2 = True Then
    txt1.Text = "4B"
    End If
     
    'Caractère L
    If txt.Text = "L" And o1 = True Then
    txt1.Text = "76"
    ElseIf txt.Text = "L" And o2 = True Then
    txt1.Text = "4C"
     
    'Caractère M
    If txt.Text = "M" And o1 = True Then
    txt1.Text = "77"
    ElseIf txt.Text = "M" And o2 = True Then
    txt1.Text = "4D"
    End If
     
    'Caractère N
    If txt.Text = "N" And o1 = True Then
    txt1.Text = "78"
    ElseIf txt.Text = "N" And o2 = True Then
    txt1.Text = "4E"
    End If
     
    'Caractère O
    If txt.Text = "O" And o1 = True Then
    txt1.Text = "79"
    ElseIf txt.Text = "O" And o2 = True Then
    txt1.Text = "4F"
    End If
     
    'Caractère P
    If txt.Text = "P" And o1 = True Then
    txt1.Text = "80"
    ElseIf txt.Text = "P" And o2 = True Then
    txt1.Text = "50"
    End If
     
    'Caractère Q
    If txt.Text = "Q" And o1 = True Then
    txt1.Text = "81"
    ElseIf txt.Text = "Q" And o2 = True Then
    txt1.Text = "51"
    End If
     
    'Caractère R
    If txt.Text = "R" And o1 = True Then
    txt1.Text = "82"
    ElseIf txt.Text = "R" And o2 = True Then
    txt1.Text = "52"
    End If
     
    'Caractère S
    If txt.Text = "S" And o1 = True Then
    txt1.Text = "83"
    ElseIf txt.Text = "S" And o2 = True Then
    txt1.Text = "53"
    End If
     
    'Caractère T
    If txt.Text = "T" And o1 = True Then
    txt1.Text = "84"
    ElseIf txt.Text = "T" And o2 = True Then
    txt1.Text = "54"
    End If
     
    'Caractère U
    If txt.Text = "U" And o1 = True Then
    txt1.Text = "85"
    ElseIf txt.Text = "U" And o2 = True Then
    txt1.Text = "55"
    End If
     
    'Caractère V
    If txt.Text = "V" And o1 = True Then
    txt1.Text = "86"
    ElseIf txt.Text = "V" And o2 = True Then
    txt1.Text = "56"
    End If
     
    'Caractère W
    If txt.Text = "W" And o1 = True Then
    txt1.Text = "87"
    ElseIf txt.Text = "W" And o2 = True Then
    txt1.Text = "57"
    End If
     
    'Caractère X
    If txt.Text = "X" And o1 = True Then
    txt1.Text = "88"
    ElseIf txt.Text = "X" And o2 = True Then
    txt1.Text = "58"
    End If
     
    'Caractère Y
    If txt.Text = "Y" And o1 = True Then
    txt1.Text = "89"
    ElseIf txt.Text = "Y" And o2 = True Then
    txt1.Text = "59"
    End If
     
    'Caractère Z
    If txt.Text = "Z" And o1 = True Then
    txt1.Text = "90"
    ElseIf txt.Text = "Z" And o2 = True Then
    txt1.Text = "5A"
    End If
    Le but, est que lorsque l'on inscrit un caractère alphabetique, en selectionnant une des 2 options, ça nous donne soit le code Ascii soit le code Héxadecimal.

    Or, les calculs de caractères s'arettent au caractère C, donc sur les 26 caractères, il n'y en a que 3 qui fonctionnent !
    Pourtant j'ai reproduit exactement le même code pour chaque caractère.

    Pouvez vous me dire ce qui ne va pas silvouplait.
    Merci

  5. #5
    Membre émérite Avatar de avigeilpro
    Homme Profil pro
    Ambulancier
    Inscrit en
    Janvier 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Creuse (Limousin)

    Informations professionnelles :
    Activité : Ambulancier
    Secteur : Transports

    Informations forums :
    Inscription : Janvier 2004
    Messages : 880
    Par défaut
    Voici un code bocoup plus court et qui fonctionne tout aussi bien :

    Code du Boutton :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    If o1 then 
    txt1.Text  = Asc(txt.Text)
    elseIf o2 then
    txt1.Text = Hex(Asc(txt.Text))
    End If
    Et voici la fonction Hex qui convertie un nombre decimal en hexa (maxi : 255):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
     
    Function Hex(Ascii As Integer) As String
    Dim A As Integer
    Dim B As Integer
     
    Dim Result As String
    Result = ""
     
    A = Int(Ascii / 16)
    B = Ascii - (A * 16)
     
    If A < 10 Then
    	Result = A
    else
    	If A = 10 Then Result = "A"
    	If A = 11 Then Result = "B"
    	If A = 12 Then Result = "C"
    	If A = 12 Then Result = "D"
    	If A = 14 Then Result = "E"
    	If A = 15 Then Result = "F"
    End If
     
    If B < 10 Then
    	Result = Result & B
    else
    	If B = 10 Then Result = Result & "A"
    	If B = 11 Then Result = Result & "B"
    	If B = 12 Then Result = Result & "C"
    	If B = 12 Then Result = Result & "D"
    	If B = 14 Then Result = Result & "E"
    	If B = 15 Then Result = Result & "F"
    End If
     
    Hex = Result
     
    End Function
    C'est largement plus court
    La connaissance seule ne suffit pas. La vraie compréhension vient de la mise en expérience.
    Règles|FAQ|Tuto

  6. #6
    Membre éclairé Avatar de Ramdoulou
    Profil pro
    Étudiant
    Inscrit en
    Novembre 2006
    Messages
    286
    Détails du profil
    Informations personnelles :
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2006
    Messages : 286
    Par défaut
    Hum au niveau des calculs je comprend pas tres bien =s
    Si ce n'est pas trop te demander, pourrais-tu détailler tes manoeuvres silteplait ?
    Merci d'avance

  7. #7
    Membre émérite Avatar de avigeilpro
    Homme Profil pro
    Ambulancier
    Inscrit en
    Janvier 2004
    Messages
    880
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Creuse (Limousin)

    Informations professionnelles :
    Activité : Ambulancier
    Secteur : Transports

    Informations forums :
    Inscription : Janvier 2004
    Messages : 880
    Par défaut
    Bien sûr:
    Un nombre Hexadecimal XY convertie en décimal cela donne X*16+Y
    Exemple :
    le nombre "A3" : A=10 donc A3 = 10*16+3 = 163

    Quand on "remonte" le calcule, on fait la division entière du nombre décimal par 16 (cela donne le premier digit) puis on récupère le reste (cela donne le deuxième digit)
    Puis on fait correspondre les digit strictements supérieurs à 9 à la lettre qui correspond, les autres restants inchangés.
    exemple :
    le nombre 185 :
    Int(185/16)=11 (185/16 = 11,5625 partie entière : 11)
    185-(11*16)=9
    Donc 185 = 11*16+9
    11 -> B d'où Hex(185) = B9

    La connaissance seule ne suffit pas. La vraie compréhension vient de la mise en expérience.
    Règles|FAQ|Tuto

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Variables string limité à 255 caractères?
    Par krfa1 dans le forum Access
    Réponses: 7
    Dernier message: 27/01/2006, 15h29
  2. [JTextField]limiter les caractères ?
    Par Baptiste Wicht dans le forum AWT/Swing
    Réponses: 8
    Dernier message: 27/12/2005, 12h12
  3. Réponses: 1
    Dernier message: 18/08/2005, 15h11
  4. limite de caractère sur un type="texte"
    Par auduma dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 18/03/2005, 14h06
  5. Varchar2 limité à 256 caractères (SQLLoader, 9i)
    Par nuke_y dans le forum SQL*Loader
    Réponses: 2
    Dernier message: 09/11/2004, 12h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo