Results 1 to 40 of 44

Thread: [RESOLVED] vb.net improve programs

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2020
    Posts
    51

    Resolved [RESOLVED] vb.net improve programs

    I,i have a little program that retrieves railway reservations for groups.
    it downloads from a website getting a json.I store data in a matrix.
    The object for the program is to know :
    a) how many station are served from that train
    b) how many people load and unload that train,selecting a particular station (ex rome,11 loaded,89 unloaded)
    c) how many people load a specific car (ex car 5-10 passenger,car 7-11 passenger)
    d) how many destinations and people selecting a particular station (ex from rome,11 passenger to florence,18 to milan,etc)
    i have a matrix with 14 columns and setted with 5000 rows (i don't think the will be more).
    i made a lot of inquiries with a for next to have all this informations,but some need a lot of time to get a response
    my progam run in a company computers so i can't install or set anything,i can just place my exe on the computer.
    in your opinion,wich would be the best way to improve my program ? datatable ? sql ?
    thank for you cooperation
    this is my code :
    json download to the matrix (stands for bidimensional array)
    i use newtonsoft json library


    Code:
    	Public matrice(5000, 15) As String
    	Public matrice2(5000, 15) As String
    	Public matrice3(5000, 15) As String
    	Dim listadest As New List(Of Destinazioni)
    	Dim listacar As New List(Of paxincarrozza)
    	Dim listapax As ArrayList = New ArrayList
    	
    	Dim listapaxcognomi As ArrayList = New ArrayList
    Code:
    Dim ser As JObject = JObject.Parse(json)
    
    			Dim data As List(Of JToken) = ser.Children().ToList
    
    
    
    			If chiamata = 1 Then
    				For Each item As JProperty In data
    					item.CreateReader()
    
    					For Each msg As JObject In item.Values
    
    						matrice(contatore, 0) = msg("departureLocationName")
    						matrice(contatore, 1) = msg("arrivalLocationName")
    						matrice(contatore, 2) = msg("pnrCode")
    						matrice(contatore, 3) = msg("serviceLevel")
    						matrice(contatore, 4) = msg("lastName")
    						matrice(contatore, 5) = msg("wagon")
    						matrice(contatore, 6) = msg("seat")
    						matrice(contatore, 7) = msg("firstName")
    						matrice(contatore, 8) = msg("transportMeanName")
    						matrice(contatore, 9) = msg("couponId")
    
    						contatore = contatore + 1
    
    
    					Next
    				Next
    
    				contatore = 0
    				
    				Do
    					If ComboBox1.Items.IndexOf(matrice(contatore, 0)) = -1 Then
    						ComboBox1.Items.Add(matrice(contatore, 0))
    					End If
    					If ComboBox1.Items.IndexOf(matrice(contatore, 1)) = -1 Then
    						ComboBox1.Items.Add(matrice(contatore, 1))
    					End If
    
    					contatore = contatore + 1
    				Loop Until matrice(contatore, 0) = Nothing
    
    				Label1.Text = "TRENO  " & (matrice(0, 8))
    then to know passenger destination or passenger load for single car :
    Code:
    		ListBox2.Items.Clear()
    
    		Dim i1 As Integer
    
    		Dim prima1 As Boolean = True
    		Dim appoggio1 As paxincarrozza
    		listacar.Clear()
    
    		For i1 = 1 To 4999
    
    			If ComboBox1.SelectedItem = (matrice(i1, 0)) Then
    				If prima1 = True Then
    
    					appoggio1.carrozza = (matrice(i1, 5))
    					appoggio1.quantita = 0
    					listacar.Add(appoggio1)
    
    
    					prima1 = False
    				End If
    				Dim appo1 As New List(Of paxincarrozza)
    				appo1.AddRange(listacar)
    				Dim trovato As Boolean = False
    
    				Dim a As Integer
    				For Each element As paxincarrozza In appo1
    
    					If element.carrozza = matrice(i1, 5) Then
    						trovato = True
    						a = listacar.IndexOf(element)
    						appoggio1 = element
    					End If
    
    				Next
    
    				If trovato = True Then
    					appoggio1.quantita = appoggio1.quantita + 1
    					listacar(a) = appoggio1
    				Else
    
    					appoggio1.carrozza = (matrice(i1, 5))
    					appoggio1.quantita = 1
    					listacar.Add(appoggio1)
    				End If
    
    
    
    			End If
    		Next
    		ListBox2.Items.Clear()
    
    		For Each element As paxincarrozza In listacar
    			ListBox2.Items.Add(element.carrozza & "   -   " & element.quantita)
    
    		Next
    the point is : a datatable with sql query would be better in your opinion ? or it just load memory without any speed increase ? i'm not sure about it.
    we are speaking about 5000 rows nothing more...
    thanks to all of you
    Last edited by eurostar_italia; Jul 11th, 2020 at 06:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width