NullReferenceException

Discussion in 'Questions (Windows Mobile)' started by WZSun, Apr 28, 2009.

  1. WZSun

    WZSun Member Licensed 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
     
  2. agraham

    agraham Expert Licensed User

    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
     
  3. WZSun

    WZSun Member Licensed 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
     
  4. WZSun

    WZSun Member Licensed 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: Apr 28, 2009
  5. agraham

    agraham Expert Licensed User

    Look in Help->Hardware-> GetDeviceID
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice