Convertir du VBA excel en VB.NET

tberniard Messages postés 2 Date d'inscription lundi 25 septembre 2006 Statut Membre Dernière intervention 28 août 2007 - 25 sept. 2006 à 14:32
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 - 8 janv. 2013 à 08:08
Bonjour,

je voudrais savoir comment s'y prendre pour convertir du code VBA Excel en VB.NET ? (si c'est possible, bien sûr)
Mon problème vient surtout de l'interprétation des UserForm et autres controles, exportés en .frm et .frx !!?? (le basic lui ne pose évidemment pas de pb)

Merci bcp.

Thierry.

5 réponses

mortalino Messages postés 6786 Date d'inscription vendredi 16 décembre 2005 Statut Membre Dernière intervention 21 décembre 2011 18
28 août 2007 à 04:43
salut,

les UserForms ne fonctionnent pas sous VB .Net

@++

<hr width="100%" size="2" />( Nouveau forum : Exclusivement Office & VBA/STRONG>
0
tberniard Messages postés 2 Date d'inscription lundi 25 septembre 2006 Statut Membre Dernière intervention 28 août 2007
28 août 2007 à 09:31
oui....je voulais savoir s'il existait une sorte de moulinette qui puisse justement convertir les .frx en controles vb.net.......

sinon, ben tant pis.....faudra que je recode tout.....

MERCI.

Thierry
0
Masea Messages postés 25 Date d'inscription lundi 11 mai 2009 Statut Membre Dernière intervention 31 décembre 2009
5 sept. 2009 à 16:39
bonjour tout le monde;
dans le cadre d'un projet en stage,on m'a demandé de réaliser une application en vb.net,en effet, il s'agit d'une application d'affectation de matériels informatiques réalisé avec access en vba
jai comencé par réaliser mon interface,migrer les tables,puis connecter ma base de données...
est arrivé le temps de programmer mon form load,cela di,je devrai utiliser le code vba employé ds ma vieille application,
jai essayer de le comprendre,c un pti peu compliké on va dir,jmy connai pa en vba..mais je voi qui a une certaine similitude entre vba et vb.net...
je sais pas par koi commencer,ni koi faire.je suis debutante,et je me sens perdu:s:s

Ce que je vous demande,c'est qu'on jetant un peti coup d'oeil sur ce code,vous essayant de morienter et de me dire koi faire,par koi commencer,koi lire...svp! devrais'je commencer par maitriser le vba...???!!!plz help

le code :


Option Compare Database
'Option Explicit

Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
'Dim Menu As TreeView
'Dim RsRun As DAO.Recordset
Dim vMatCondition As String
Dim DesktopSelect As String
Dim LaptopSelect As String
Dim StationSelect As String
Dim EcranSelect As String
Dim PrinterSelect As String
Dim ScannerSelect As String
Dim ConsoSelect As String
Dim SelectOrder As String
Dim vwhere As String
Private vFileList(10, 1) As String


Private Sub Form_Load()
Set dbs = CurrentDb
SetSelects
FormInit
CadreInv.Value = 2
CadreInvMAJ

Set rs = dbs.OpenRecordset(Me.ComboBoxAgent.RowSource)
ComboBoxAgent.Value = rs.Fields(0).Value
CadreAgentMAJ
rs.Close
End Sub



définition de la procédure FormInit :
Sub FormInit()
Dim vLbl As Label
Dim vChk As CheckBox

InitListInfo
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("select marque, count(*) as cnt from AllArticles_IDs_Mvmts as a " & _
" where Quantité >=0 and Marque is not null and TypeArticle <> 'Conso' " & _
" group by marque order by count(*) desc;")
rs.MoveLast
rs.MoveFirst
For i = 1 To rs.RecordCount
If i > 8 Then Exit For
Set vChk = Me.Controls("chkMarque" & Format(i, "00"))
Set vLbl = Me.Controls("lblMarque" & Format(i, "00"))
vLbl.Caption = rs!Marque
rs.MoveNext
Next i

With Me.ListeInvSUM
.ColumnCount = vListInfo(0, 0).colWidth
.ColumnWidths = vListInfo(0, 0).colName
.ColumnHeads = True
End With
With Me.ListeInv
.ColumnCount = vListInfo(1, 0).colWidth
.ColumnWidths = vListInfo(1, 0).colName
.ColumnHeads = True
' Debug.Print .RowSource
End With
With Me.ListeAgent
.ColumnCount = vListInfo(2, 0).colWidth
.ColumnWidths = vListInfo(2, 0).colName
.ColumnHeads = True
End With
Me.CadreInvTypeAgent.Value = 1
Me.CadreAgentTypeAgent.Value = 1
Me.chkPrêt = False
Me.PriseEnCharge = Now()
Me.DateSouhaitéePC = Now()
Me.DéchargePlanned = Now() + 1

End Sub


la fonction setSelect:
Private Sub SetSelects()
Dim TypeTri As Integer
Dim vMatType As String

For i = 0 To 9
For j = 0 To 4
SQLSelect(i, j) = ""
Next j
Next i

SQLSelect(0, 0) = "Article_IDs"
SQLSelect(0, 1) = "Portable"
SQLSelect(0, 2) = "Article_Mvmts"
SQLSelect(1, 0) = "Article_IDs"
SQLSelect(1, 1) = "Station"
SQLSelect(1, 2) = "Article_Mvmts"
SQLSelect(2, 0) = "Article_IDs"
SQLSelect(2, 1) = "PC"
SQLSelect(2, 2) = "Article_Mvmts"
SQLSelect(3, 0) = "Article_IDs"
SQLSelect(3, 1) = "Ecran"
SQLSelect(3, 2) = "Article_Mvmts"
SQLSelect(4, 0) = "Article_IDs"
SQLSelect(4, 1) = "Imprimante"
SQLSelect(4, 2) = "Article_Mvmts"
SQLSelect(5, 0) = "Article_IDs"
SQLSelect(5, 1) = "Scanner"
SQLSelect(5, 2) = "Article_Mvmts"
SQLSelect(6, 0) = "Article_IDs"
SQLSelect(6, 1) = "Conso"
SQLSelect(6, 2) = "Article_Mvmts"
SelectOrder = " order by 3"

SQLSelect(9, 3) = ""
For i = 0 To 6
SQLSelect(i, 4) = "SELECT Matricule, i.MIId, " & i & " as MatTypeTri , TypeArticle, " & _
" a.Marque & ' ' & a.Model as Mat_Model, a.Désignation, a.Marque, a.Model, Sum(m.Quantité) as Qté " & _
" From (" & SQLSelect(i, 0) & " as i Inner Join " & SQLSelect(i, 2) & " as m ON " & _
" (i.Année m.Année) and (i.IDInv m.IDInv)) Inner Join Article as a on i.MIId = d.MIId " & _
" where m.MatType = '" & SQLSelect(i, 1) & "' WHERECOND" & _
" Group by Matricule, i.MIId, " & i & " , '" & SQLSelect(i, 1) & "', a.Marque & ' ' & a.Model, " & _
" a.Désignation, a.Marque, a.Model having Sum(m.Quantité) > 0" & _
" "

SQLSelect(9, 4) = SQLSelect(9, 4) & " UNION " & SQLSelect(i, 4)

SQLSelect(i, 3) = "SELECT Matricule, m.Année, m.IDInv, " & i & " as MatTypeTri , TypeArticle, " & _
" a.Désignation, i.SN, i.Inv, m.PriseEnCharge, Sum(m.Quantité) as Qté " & _
" From (" & SQLSelect(i, 0) & " as i Inner Join " & SQLSelect(i, 2) & " as m On " & _
" (i.Année m.Année) and (i.IDInv m.IDInv)) Inner Join Article as a on i.MIId = d.MIId " & _
" where m.MatType = '" & SQLSelect(i, 1) & "' WHERECOND" & _
" Group by Matricule, m.Année, m.IDInv, " & i & " , '" & SQLSelect(i, 1) & "', a.Désignation, i.SN, i.Inv, " & _
" m.PriseEnCharge having Sum(m.Quantité) > 0" & _
" "
SQLSelect(9, 3) = SQLSelect(9, 3) & " UNION " & SQLSelect(i, 3)
Next i

SQLSelect(9, 3) = Right(SQLSelect(9, 3), Len(SQLSelect(9, 3)) - 7)
SQLSelect(9, 4) = Right(SQLSelect(9, 4), Len(SQLSelect(9, 4)) - 7)
End Sub


Fct CadreInvMAJ



Private Sub CadreInvMAJ()
SQLStr CadreSQL(IIf(Me.CadreInv.Value 1, "All", IIf(Me.CadreInv.Value = 2, "StockDSI", "Agent")), _
IIf(IsNull(Me.ComboBoxInv.Value), -1, Me.ComboBoxInv.Value), _
4, Me.ChkDesktopInv, Me.ChkMonitorInv, Me.ChkLaptopInv, _
Me.ChkStationInv, Me.ChkScannerInv, Me.ChkPrinterInv, Me.ChkConsoInv, _
Me.ChkTousInv, Me.ChkSansDechargeInv, getMarchéCond(), True)

Me.ListeInvSUM.RowSource = SQLStr
Me.ListeInvSUM.Requery

SQLStr CadreSQL(IIf(Me.CadreInv.Value 1, "All", IIf(Me.CadreInv.Value = 2, "StockDSI", "Agent")), _
IIf(IsNull(Me.ComboBoxInv.Value), -1, Me.ComboBoxInv.Value), _
3, Me.ChkDesktopInv, Me.ChkMonitorInv, Me.ChkLaptopInv, _
Me.ChkStationInv, Me.ChkScannerInv, Me.ChkPrinterInv, Me.ChkConsoInv, Me.ChkTousInv, _
Me.ChkSansDechargeInv, getMarchéCond, True)
Me.ListeInv.RowSource = SQLStr
Me.ListeInv.Requery
End Sub
0
Alooshi Messages postés 2 Date d'inscription jeudi 19 avril 2012 Statut Membre Dernière intervention 19 avril 2012
19 avril 2012 à 15:04
Bonjour à tous, je suis actuellement en stage et j'ai comme mission de convertir du code VBA Excel en VB.NET (VSTO) , merci de me répondre si vous avez déjà trouvez une solution.

Merci bcp pour votre aide.

Ali
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 219
8 janv. 2013 à 08:08
Bonjour,
même réponse qu'ici :
Tapez le texte de l'url ici.
Etonnante, cette "pluie" soudaine de questions à ce sujet ...


________________________
Réponse exacte ? => "REPONSE ACCEPTEE" facilitera les recherches.
Pas d'aide en ligne installée ? => ne comptez pas sur moi pour simplement répéter son contenu. Je n'interviendrai que si nécessité de la compléter.
0