NullReferenceException

WZSun

Member
Licensed User
Longtime User
Hi,
I had some old projects which works previously.. but now encountered the below error, after I compiled it with Optimised compilation:

An error occured on sub_main_numonly.
NullReferenceException
Continue?

Sub NumOnly(x)
t = ""
For i = 1 To StrLength(x)
y = StringMid(x,i,1)
If (Asc(y)>47) AND (Asc(y)<58) Then t = t & y
Next
Return t
End Sub

what could be the problem?

Thanks
WZSun
 

agraham

Expert
Licensed User
Longtime User
For i = 1 To StrLength(x)
Possibly this line causing a string access beyond it's length if StringMid (where is it from?) uses 0 based indexing for its' start parameter - otherwise I've no idea without more information (does it run in the IDE?) and seeing the code in context.

For i = 0 to StrLength(x) -1
 

WZSun

Member
Licensed User
Longtime User
Hi Agraham,
Both desktop and PC2003 PDA works fine without error but when the error comes about on a WM6.1 PDA

Sub StringMid(strings,StartIndex,EndIndex)
If StrLength(strings) < 1 Then Return
Return SubString(strings,StartIndex-1,EndIndex)
End Sub
 

WZSun

Member
Licensed User
Longtime User
Hi,
I added some msgbox for debugging.. somehow on the WM6.1 pda (asus 620), the following return null value for 'x' which is then used to check the strlength(x)

HWid = hw.GetDeviceID

why is this so? does the getDeviceID work on WM6.1 smartphone? Or must we use IMEI or UUID detection? If so, how to detect/retrieve the deviceID?

The funny thing is my PC2003 is an O2 mini while the WM6.1 is an AsusP320..both are smartphones too.

Rgds
WZSun
 
Last edited:
Top