ListBox_SelectionChanged problem v.6.30

Discussion in 'Questions (Windows Mobile)' started by numerus, Aug 14, 2008.

  1. numerus

    numerus Member Licensed User

    My application compiled wit Basic4ppc ver. 5.80 works fine on the device (I use Asus A632, WM5). The same code compiled with Basic4ppc ver. 6.30 gives Unexpected Error or Invalid Cast Exeption error. My code is very large but I'm sure the problem is only with ListBox_SelectionChanged events. I made simple code to show you the way I use ListBox_SelectionChanged event. This code gives similar errors after compliation with ver. 6.30 (Compile/Device EXE). Can you help me to find my mistake. What is correct way to use this event with ver. 6.30.
    Code:
    Sub Globals
        
    'Declare the global variables here.
        Dim NR(500As STRING            ' Point name
        Dim X(500),Y(500As DOUBLE   ' Coordinates
        Dim POINT1,POINT2
        
    Dim NAME1,NAME2
    End Sub
    '   ** CALCULATES DISTANCE FROM COORDINATES
    Sub App_Start
       Form1.Show
       POINT1=-
    1
       POINT2=-
    1   
    ' testing data    
       NR(0)=100
       X(
    0)=52000.0
       Y(
    0)=35000.0
       
    For I=1 To 99
         NR(I)=NR(I-
    1)+ 1
         X(I)=X(I-
    1)+ 50.
         Y(I)=Y(I-
    1)+ 60.
       
    Next I
    ' show points for selecting   
       For I=0 To 99
                 ListBox1.Add(NR(I))
       ListBox2.Add(NR(I))
       
    Next I 
    End Sub

    Sub ListBox1_SelectionChanged (Index, Value)  'select first point
        POINT1=Index
        NAME1=Value
        Label6.Text=NAME1
        DIST
    End Sub

    Sub ListBox2_SelectionChanged (Index, Value)  'select second point
        POINT2=Index
        NAME2=Value
        Label8.Text=NAME2
        DIST
    End Sub

    Sub Button1_Click
        AppClose
    End Sub

    Sub DIST
     
    Dim DX,DY,S
        
    If POINT1>-1 AND POINT2>-1 Then
           DX=X(POINT1)-X(POINT2)
           DY=Y(POINT1)-Y(POINT2)
           S=DX*DX+DY*DY              
    ' computed distance
           Label2.Text=Format(Sqrt(S),"F2"
    End If   
    End Sub
    Thanks
    numerus
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There is a bug in the legacy compiler that causing this fault.
    This bug will be fixed in the next release.

    You have a small typo in the following lines:
    Code:
    ' testing data     
        NR(0)=100
        X(
    0)=52000.0
        Y(
    0)=35000.0
        
    For I=1 To 99
          NR(I)=NR(I-
    1)+ 1
          X(I)=X(I-
    1)+ 50[COLOR=Red]. [/COLOR]'Remove the dots
          Y(I)=Y(I-1)+ 60[COLOR=Red].[/COLOR] 

        
    Next I
    The solution is to use the much improved optimized compiler.
     
  3. numerus

    numerus Member Licensed User

    Hi,
    Thanks Erel for the reply.
    To tell the true I was waiting for more optimistic diagnosis. It is a pity.

    You are right, but I must take also enduser into consideration who prefers fully functional exe without suplementary installation for his device (I mean .Net 2 for older devices). So, unfortunately probably I must came back to the old version of Basic4ppc.

    Maybe patch for version 6.30?

    Regards
    and thank you for your useful work!

    numerus
     
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