
Feb 7th, 2018, 11:51 PM
#1
Thread Starter
Lively Member
[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~

Feb 8th, 2018, 12:01 PM
#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.

Feb 8th, 2018, 01:38 PM
#3
Thread Starter
Lively Member
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*22))/2 = (100  12)/2 = 44
????????

Feb 8th, 2018, 12:24 PM
#4
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.

Feb 8th, 2018, 03:15 PM
#5
Re: SMS PDU Calculation
You have your parentheses wrong.
It isn't (100  (7*22))/2 = (100  12)/2 = 44
its (100  (7)*22)/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
Last edited by passel; Feb 8th, 2018 at 03:28 PM.

Feb 8th, 2018, 05:45 PM
#6
Thread Starter
Lively Member
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

Forum Rules

Click Here to Expand Forum to Full Width
