Convertir de VB.NET en VB6

SIMSIMBABO Messages postés 12 Date d'inscription jeudi 9 septembre 2010 Statut Membre Dernière intervention 14 octobre 2010 - 21 sept. 2010 à 00:46
SIMSIMBABO Messages postés 12 Date d'inscription jeudi 9 septembre 2010 Statut Membre Dernière intervention 14 octobre 2010 - 23 sept. 2010 à 18:08
Salut,
je dispose d'un code en VB.NET et je veux le convertir en VB6.
pouvez vous m'aider sachant que je ne maitrise pas le VB.NET.
merci beaucoup.

2 réponses

NSUADI Messages postés 540 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 1 février 2013 2
21 sept. 2010 à 00:50
Pourquoi quitter de vb.net à vb6,c'est comme régresser!!!
Mais bon,à toi de voir!!Tu peux toujours y aller et poste donc ton code...

Ce qui compte,ce n'est pas ce qu'on a mais plutôt ce que l'on fait avec ce qu'on a...

Visual Basic .Net is the best
and vb6.0
0
SIMSIMBABO Messages postés 12 Date d'inscription jeudi 9 septembre 2010 Statut Membre Dernière intervention 14 octobre 2010
23 sept. 2010 à 18:08
Salut,
veuillez m'aidez SVP c'est urgent.
voici le code en VB.NET
Imports System.Data
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim listeSolution As Hashtable = affectationCamion()
Dim ss As String

For Each i As Int16 In listeSolution.Keys
lstPossibilites.Items.Add(Convert.ToString(listeSolution.Item(i)))
lstPossibilites.Refresh()
Next
End Sub
Private Function choixDesBesoins() As ArrayList
Dim lstDesBesoins As ArrayList = New ArrayList

If TxtChoix1.Text <> "" Then
lstDesBesoins.Add(TxtChoix1.Text)
End If
If TxtChoix2.Text <> "" Then
lstDesBesoins.Add(TxtChoix2.Text)
End If
If TxtChoix3.Text <> "" Then
lstDesBesoins.Add(TxtChoix3.Text)
End If

Return lstDesBesoins
End Function

Private Function affectationCamion() As Hashtable

Dim tableDonnees As DataTable = chargerLesDonnees()
Dim listeBesoins As ArrayList = choixDesBesoins()
Dim listeCamions As Hashtable = initialiserListeCamion()
Dim listeSolutions As Hashtable = New Hashtable
Dim listeCamionPourSolution As ArrayList


Dim trax As Int16 = 0
Dim site As Int16 = 0
Dim qte As Int16 = 0
Dim somme, cout, b, i As Int16
Dim solution As String

'Recupéraon de la liste des choix : triplet (trax - site - quantite)
For f As Int16 = 0 To listeBesoins.Count - 1
listeCamions = initialiserListeCamion()
solution = "Sol " + f.ToString
cout = 0
i = f
b = 1
While b <= listeBesoins.Count
If i >= listeBesoins.Count Then
i = 0
End If
somme = 0
listeCamionPourSolution = New ArrayList

trax = CInt(listeBesoins.Item(i).ToString.Split(";")(0))
site = CInt(listeBesoins.Item(i).ToString.Split(";")(1))
qte = CInt(listeBesoins.Item(i).ToString.Split(";")(2))

Dim listeCapacitePossible As Hashtable = getLstCamionsPossible(tableDonnees, listeCamions, trax, site)
Dim listeCapacites = Array.CreateInstance(GetType(System.Int16), listeCapacitePossible.Keys.Count)
Dim j As Integer = 0
For Each capacite As Int16 In listeCapacitePossible.Keys
listeCapacites.SetValue(capacite, j)
j += 1
Next
Array.Sort(listeCapacites)
'Dim maxi As Integer = listeCapacites(0)
Dim lstCamionDeLaCapacite As ArrayList
For j = listeCapacitePossible.Keys.Count - 1 To 0 Step -1
lstCamionDeLaCapacite = listeCapacitePossible.Item(listeCapacites(j))
Dim k As Integer = 0
While (somme < (qte - 50) And k < lstCamionDeLaCapacite.Count)
If listeCamions.Contains(lstCamionDeLaCapacite(k)) Then
somme += Convert.ToInt16(listeCapacites(j))
listeCamionPourSolution.Add(lstCamionDeLaCapacite(k))
listeCamions.Remove(lstCamionDeLaCapacite(k))
k += 1
End If
End While
If somme > (qte - 50) Then
Exit For
End If
Next

solution += " >> trax" + trax.ToString + "-Site" + site.ToString
solution += "(Capacite : " + somme.ToString + ") "
cout = listeCamionPourSolution.Count
For j = 0 To listeCamionPourSolution.Count - 1
solution += Convert.ToString(listeCamionPourSolution(j)) + " | "
Next

i += 1
b += 1
End While
solution +"(cout " + cout.ToString + ") *** "
listeSolutions.Add(f, solution)
Next

Return listeSolutions
End Function
Private Function initialiserListeCamion() As Hashtable
Dim listeCamions As Hashtable = New Hashtable
Dim val As Short = 211
listeCamions.Add(val, False)
val = 212
listeCamions.Add(val, False)
val = 214
listeCamions.Add(val, False)
val = 216
listeCamions.Add(val, False)
val = 218
listeCamions.Add(val, False)
val = 219
listeCamions.Add(val, False)
val = 220
listeCamions.Add(val, False)

Return listeCamions

End Function
Private Function getLstCamionsPossible(ByRef tableDonnees As DataTable, ByRef listeCamion As Hashtable, ByVal trax As Integer, ByVal site As Integer) As Hashtable
Dim lstCapacitesCamions As Hashtable = New Hashtable
Dim lstCamions As ArrayList = New ArrayList

For Each ligne As DataRow In tableDonnees.Rows
If CInt(ligne("trax")) trax And CInt(ligne("site")) site And listeCamion.Contains(Convert.ToInt16(ligne("camion"))) Then
If lstCapacitesCamions.Contains(Convert.ToInt16(ligne("capacite"))) Then
DirectCast(lstCapacitesCamions(ligne("capacite")), ArrayList).Add(Convert.ToInt16(ligne("camion")))
Else
lstCamions = New ArrayList
lstCamions.Add(Convert.ToInt16(ligne("camion")))
lstCapacitesCamions.Add(Convert.ToInt16(ligne("capacite")), lstCamions)
End If
End If
Next
Return lstCapacitesCamions
End Function

Private Function chargerLesDonnees() As DataTable

Dim lstDonnees As ArrayList = New ArrayList
'Trax : 322 - site : 1
lstDonnees.Add("322;1;211;100")
lstDonnees.Add("322;1;212;100")
lstDonnees.Add("322;1;214;140")
lstDonnees.Add("322;1;216;120")
lstDonnees.Add("322;1;218;160")
lstDonnees.Add("322;1;219;160")
lstDonnees.Add("322;1;220;160")
'- site : 2
lstDonnees.Add("322;2;211;80")
lstDonnees.Add("322;2;212;80")
lstDonnees.Add("322;2;214;100")
lstDonnees.Add("322;2;216;100")
lstDonnees.Add("322;2;218;128")
lstDonnees.Add("322;2;219;128")
lstDonnees.Add("322;2;220;128")
'- site : 3
lstDonnees.Add("322;3;211;100")
lstDonnees.Add("322;3;212;120")
lstDonnees.Add("322;3;214;140")
lstDonnees.Add("322;3;216;140")
lstDonnees.Add("322;3;218;192")
lstDonnees.Add("322;3;219;192")
lstDonnees.Add("322;3;220;192")
'- site : 4
lstDonnees.Add("322;4;211;60")
lstDonnees.Add("322;4;212;60")
lstDonnees.Add("322;4;214;100")
lstDonnees.Add("322;4;216;80")
lstDonnees.Add("322;4;218;128")
lstDonnees.Add("322;4;219;128")
lstDonnees.Add("322;4;220;128")
'----------------Fin trax 322

'Trax : 328 - site : 1
lstDonnees.Add("328;1;211;100")
lstDonnees.Add("328;1;212;100")
lstDonnees.Add("328;1;214;140")
lstDonnees.Add("328;1;216;140")
lstDonnees.Add("328;1;218;192")
lstDonnees.Add("328;1;219;192")
lstDonnees.Add("328;1;220;192")
'- site : 2
lstDonnees.Add("328;2;211;80")
lstDonnees.Add("328;2;212;80")
lstDonnees.Add("328;2;214;120")
lstDonnees.Add("328;2;216;120")
lstDonnees.Add("328;2;218;160")
lstDonnees.Add("328;2;219;160")
lstDonnees.Add("328;2;220;160")
'- site : 3
lstDonnees.Add("328;3;211;120")
lstDonnees.Add("328;3;212;120")
lstDonnees.Add("328;3;214;160")
lstDonnees.Add("328;3;216;140")
lstDonnees.Add("328;3;218;192")
lstDonnees.Add("328;3;219;192")
lstDonnees.Add("328;3;220;192")
'- site : 4
lstDonnees.Add("328;4;211;60")
lstDonnees.Add("328;4;212;80")
lstDonnees.Add("328;4;214;100")
lstDonnees.Add("328;4;216;100")
lstDonnees.Add("328;4;218;128")
lstDonnees.Add("328;4;219;128")
lstDonnees.Add("328;4;220;128")
'----------------Fin trax 328

'Trax : 329 - site : 1
lstDonnees.Add("329;1;211;100")
lstDonnees.Add("329;1;212;100")
lstDonnees.Add("329;1;214;140")
lstDonnees.Add("329;1;216;120")
lstDonnees.Add("329;1;218;160")
lstDonnees.Add("329;1;219;160")
lstDonnees.Add("329;1;220;160")
'- site : 2
lstDonnees.Add("329;2;211;80")
lstDonnees.Add("329;2;212;80")
lstDonnees.Add("329;2;214;120")
lstDonnees.Add("329;2;216;100")
lstDonnees.Add("329;2;218;128")
lstDonnees.Add("329;2;219;128")
lstDonnees.Add("329;2;220;128")
'- site : 3
lstDonnees.Add("329;3;211;120")
lstDonnees.Add("329;3;212;120")
lstDonnees.Add("329;3;214;160")
lstDonnees.Add("329;3;216;140")
lstDonnees.Add("329;3;218;192")
lstDonnees.Add("329;3;219;192")
lstDonnees.Add("329;3;220;192")
'- site : 4
lstDonnees.Add("329;4;211;60")
lstDonnees.Add("329;4;212;60")
lstDonnees.Add("329;4;214;100")
lstDonnees.Add("329;4;216;100")
lstDonnees.Add("329;4;218;128")
lstDonnees.Add("329;4;219;128")
lstDonnees.Add("329;4;220;128")
'----------------Fin trax 329

Dim dt As DataTable = New DataTable()
dt.Columns.Add("site", GetType(System.Int16))
dt.Columns.Add("trax", GetType(System.Int16))
dt.Columns.Add("camion", GetType(System.Int16))
dt.Columns.Add("capacite", GetType(System.Int16))
dt.Columns.Add("utilise", GetType(System.Boolean))
Dim dr As DataRow
Dim ss As String

For i As Integer = 0 To lstDonnees.Count - 1
dr = dt.NewRow()
ss = lstDonnees.Item(i)

dr("trax") = ss.Split(";")(0)
dr("site") = ss.Split(";")(1)
dr("camion") = ss.Split(";")(2)
dr("capacite") = ss.Split(";")(3)
dr("utilise") = False

dt.Rows.Add(dr)
Next

Return dt
End Function

End Class
0
Rejoignez-nous