Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
>>>Hello i have the following code
>>>
>> >
>>>MESSAGEBOX(thisform.pageframe1.page5.txtnum2.Value )&& pelt0006
>>> MESSAGEBOX(cNextnum)&& pelt0006
>>> IF cnext == thisform.pageframe1.page5.txtnum2.Value
>>> MESSAGEBOX('caught')
>>> ELSE
>>> MESSAGEBOX('not caught')
>>> ENDIF
>>>
>>>
>>>Any one can tell me why the message "Not Caught" comes up?
>>>i use if cnextnum== and = no difference
>>
>>Try
>>
>>IF ALLTRIM(cnext) == ALLTRIM(thisform.pageframe1.page5.txtnum2.Value)
>> MESSAGEBOX('caught')
>>ELSE
>> MESSAGEBOX('not caught')
>>ENDIF
>>
>yea alltrim works(thou i have to figure what it really does)
>YOu >all :D
The textbox can have spaces in the value -- it is based on the size/length of the textbox. The == means exactly the same so any spaces in one that is not in the other is considered different. Also, the case of the text matters as well. So you might want:
IF UPPER(ALLTRIM(cnext)) == UPPER(ALLTRIM(thisform.pageframe1.page5.txtnum2.Value))
...
If the above had been:
IF thisform.pageframe1.page5.txtnum2.Value = cnext
...
Then it could possibly match -- the cnext field controls the amount of comparison between the two values:
"ABC" = "ABC" && true
"ABCDE" = "ABC" && true
"ABCDE D" = "ABC" && true again
"ABCDE" = "ABC " && not true -- the spaces in the second makes it different from the first
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement