View Single Post
  #1 (permalink)  
Old 08-14-2008, 08:30 AM
numerus numerus is offline
Newbie
 
Join Date: May 2007
Posts: 2
Default ListBox_SelectionChanged problem v.6.30

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(500) As STRING            ' Point name
    Dim X(500),Y(500) As 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
Attached Files
File Type: sbp Distance.sbp (2.1 KB, 4 views)
Reply With Quote