1. [RESOLVED] SMS PDU Calculation

Guyz,
What is the meaning of it?? I need a strip down of it...:

Code:
`PDUCodes(i).Length - Val("&H" & Mid(PDUCodes(i), 1, 2)) * 2 - 2) / 2`
PDUCodes(i) is a loooong hex string of SMS PDU. That's for sure... Like:

Code:
`07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E`
and the final result should come 42 after this calculation.

Ref: http://www.developershome.com/sms/cmgsCommand4.asp

Mshu~

2. Re: SMS PDU Calculation

This part: Mid(PDUCodes(i), 1, 2)
...gets the first two characters of PDUCodes(i), so is the same as "07"

This part: Val("&H" & "07")
...gets the numerical value of the Hex value (converted to decimal), so in this case 7.

The rest is simple maths, so you can probably work all that out yourself.

3. Re: SMS PDU Calculation

Originally Posted by aq_mishu
...
and the final result should come 42 after this calculation.
...
I tested it and the final result is 42, so the code works.

4. Re: SMS PDU Calculation

Originally Posted by si_the_geek

The rest is simple maths, so you can probably work all that out yourself.
If i'm not that stupid in maths:

Code:
`(PDUCodes(i).Length - Val("&H" & Mid(PDUCodes(i), 1, 2)) * 2 - 2) / 2`
for
Code:
`07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E`
= 100 chars

VAL(&H07) = 07

hence it is: (100 - (7*2-2))/2 = (100 - 12)/2 = 44

????????

5. Re: SMS PDU Calculation

It isn't (100 - (7*2-2))/2 = (100 - 12)/2 = 44
its (100 - (7)*2-2)/2 i.e. (100 - 7 * 2 - 2) / 2

Code:
```(PDUCodes(i).Length - Val("&H" & Mid(PDUCodes(i), 1, 2)) * 2 - 2) / 2
(       100         -    (               7             ) * 2 - 2) / 2```
If you type in your immediate window...
? (100 - 7 * 2 - 2)/2
you get
42

The order of operations is:
Code:
```(100 - 7 * 2 - 2) / 2
(100 -  14   - 2) / 2
(   86       - 2) / 2
(       84      ) / 2
42```

6. Re: SMS PDU Calculation

OKdoki!!

Yep!! I discovered it after you said... p a r e n t h e s i s huh!!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured