dans mon programme suivant, je n'arrive pas à utiliser ListIndex
pouvez vous m'aider
merci
Public
Class Form1
Inherits System.Windows.Forms.Form#
Region " Code généré par le Concepteur Windows Form "
Public
Sub
New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
End
Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
Protected
Overloads
Overrides
Sub Dispose(
ByVal disposing
As
Boolean)
If disposing
Then
If
Not (components
Is
Nothing)
Thencomponents.Dispose()
End
If
End
If
MyBase.Dispose(disposing)
End
Sub
'Requis par le Concepteur Windows Form
Private components
As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend
WithEvents fer
As System.Windows.Forms.Button
Friend
WithEvents Label1
As System.Windows.Forms.Label
Friend
WithEvents Label2
As System.Windows.Forms.Label
Friend
WithEvents Label3
As System.Windows.Forms.Label
Friend
WithEvents Label4
As System.Windows.Forms.Label
Friend
WithEvents Label5
As System.Windows.Forms.Label
Friend
WithEvents Label6
As System.Windows.Forms.Label
Friend
WithEvents Label7
As System.Windows.Forms.Label
Friend
WithEvents Label10
As System.Windows.Forms.Label
Friend
WithEvents Label11
As System.Windows.Forms.Label
Friend
WithEvents NOM
As System.Windows.Forms.ComboBox
Friend
WithEvents ADR1
As System.Windows.Forms.TextBox
Friend
WithEvents ADR2
As System.Windows.Forms.TextBox
Friend
WithEvents VIL
As System.Windows.Forms.TextBox
Friend
WithEvents PAY
As System.Windows.Forms.TextBox
Friend
WithEvents TEL
As System.Windows.Forms.TextBox
Friend
WithEvents FAX
As System.Windows.Forms.TextBox
Friend
WithEvents EMA
As System.Windows.Forms.TextBox
Friend
WithEvents ENT
As System.Windows.Forms.ComboBox<System.Diagnostics.DebuggerStepThrough()>
Private
Sub InitializeComponent()
Me.ENT =
New System.Windows.Forms.ComboBox
Me.fer =
New System.Windows.Forms.Button
Me.NOM =
New System.Windows.Forms.ComboBox
Me.ADR1 =
New System.Windows.Forms.TextBox
Me.ADR2 =
New System.Windows.Forms.TextBox
Me.VIL =
New System.Windows.Forms.TextBox
Me.PAY =
New System.Windows.Forms.TextBox
Me.TEL =
New System.Windows.Forms.TextBox
Me.FAX =
New System.Windows.Forms.TextBox
Me.EMA =
New System.Windows.Forms.TextBox
Me.Label1 =
New System.Windows.Forms.Label
Me.Label2 =
New System.Windows.Forms.Label
Me.Label3 =
New System.Windows.Forms.Label
Me.Label4 =
New System.Windows.Forms.Label
Me.Label5 =
New System.Windows.Forms.Label
Me.Label6 =
New System.Windows.Forms.Label
Me.Label7 =
New System.Windows.Forms.Label
Me.Label10 =
New System.Windows.Forms.Label
Me.Label11 =
New System.Windows.Forms.Label
Me.SuspendLayout()
'
'ENT
'
Me.ENT.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.ENT.Location =
New System.Drawing.Point(120, 16)
Me.ENT.Name = "ENT"
Me.ENT.Size =
New System.Drawing.Size(328, 27)
Me.ENT.TabIndex = 0
'
'fer
'
Me.fer.Location =
New System.Drawing.Point(344, 352)
Me.fer.Name = "fer"
Me.fer.Size =
New System.Drawing.Size(64, 32)
Me.fer.TabIndex = 1
Me.fer.Text = "Fermer"
'
'NOM
'
Me.NOM.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.NOM.Location =
New System.Drawing.Point(120, 48)
Me.NOM.Name = "NOM"
Me.NOM.Size =
New System.Drawing.Size(328, 27)
Me.NOM.TabIndex = 0
'
'ADR1
'
Me.ADR1.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.ADR1.Location =
New System.Drawing.Point(120, 80)
Me.ADR1.Name = "ADR1"
Me.ADR1.Size =
New System.Drawing.Size(328, 26)
Me.ADR1.TabIndex = 2
Me.ADR1.Text = ""
'
'ADR2
'
Me.ADR2.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.ADR2.Location =
New System.Drawing.Point(120, 112)
Me.ADR2.Name = "ADR2"
Me.ADR2.Size =
New System.Drawing.Size(328, 26)
Me.ADR2.TabIndex = 2
Me.ADR2.Text = ""
'
'VIL
'
Me.VIL.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.VIL.Location =
New System.Drawing.Point(120, 144)
Me.VIL.Name = "VIL"
Me.VIL.Size =
New System.Drawing.Size(328, 26)
Me.VIL.TabIndex = 2
Me.VIL.Text = ""
'
'PAY
'
Me.PAY.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.PAY.Location =
New System.Drawing.Point(120, 176)
Me.PAY.Name = "PAY"
Me.PAY.Size =
New System.Drawing.Size(328, 26)
Me.PAY.TabIndex = 2
Me.PAY.Text = ""
'
'TEL
'
Me.TEL.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.TEL.Location =
New System.Drawing.Point(120, 208)
Me.TEL.Name = "TEL"
Me.TEL.Size =
New System.Drawing.Size(328, 26)
Me.TEL.TabIndex = 2
Me.TEL.Text = ""
'
'FAX
'
Me.FAX.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.FAX.Location =
New System.Drawing.Point(120, 240)
Me.FAX.Name = "FAX"
Me.FAX.Size =
New System.Drawing.Size(328, 26)
Me.FAX.TabIndex = 2
Me.FAX.Text = ""
'
'EMA
'
Me.EMA.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.EMA.Location =
New System.Drawing.Point(120, 272)
Me.EMA.Name = "EMA"
Me.EMA.Size =
New System.Drawing.Size(328, 26)
Me.EMA.TabIndex = 2
Me.EMA.Text = ""
'
'Label1
'
Me.Label1.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label1.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label1.Location =
New System.Drawing.Point(8, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size =
New System.Drawing.Size(104, 16)
Me.Label1.TabIndex = 3
Me.Label1.Text = "ENTREPRISE"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label2
'
Me.Label2.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label2.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label2.Location =
New System.Drawing.Point(8, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size =
New System.Drawing.Size(104, 16)
Me.Label2.TabIndex = 3
Me.Label2.Text = "NOM"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label3
'
Me.Label3.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label3.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label3.Location =
New System.Drawing.Point(8, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size =
New System.Drawing.Size(104, 16)
Me.Label3.TabIndex = 3
Me.Label3.Text = "ADRESSE"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label4
'
Me.Label4.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label4.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label4.Location =
New System.Drawing.Point(8, 120)
Me.Label4.Name = "Label4"
Me.Label4.Size =
New System.Drawing.Size(104, 16)
Me.Label4.TabIndex = 3
Me.Label4.Text = "ADRESSE"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label5
'
Me.Label5.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label5.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label5.Location =
New System.Drawing.Point(8, 152)
Me.Label5.Name = "Label5"
Me.Label5.Size =
New System.Drawing.Size(104, 16)
Me.Label5.TabIndex = 3
Me.Label5.Text = "VILLE"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label6
'
Me.Label6.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label6.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label6.Location =
New System.Drawing.Point(8, 184)
Me.Label6.Name = "Label6"
Me.Label6.Size =
New System.Drawing.Size(104, 16)
Me.Label6.TabIndex = 3
Me.Label6.Text = "PAYS"
Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label7
'
Me.Label7.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label7.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label7.Location =
New System.Drawing.Point(8, 248)
Me.Label7.Name = "Label7"
Me.Label7.Size =
New System.Drawing.Size(104, 16)
Me.Label7.TabIndex = 3
Me.Label7.Text = "FAX"
Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label10
'
Me.Label10.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label10.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label10.Location =
New System.Drawing.Point(8, 280)
Me.Label10.Name = "Label10"
Me.Label10.Size =
New System.Drawing.Size(104, 16)
Me.Label10.TabIndex = 3
Me.Label10.Text = "EMAIL"
Me.Label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label11
'
Me.Label11.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label11.Font =
New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0,
Byte))
Me.Label11.Location =
New System.Drawing.Point(8, 216)
Me.Label11.Name = "Label11"
Me.Label11.Size =
New System.Drawing.Size(104, 16)
Me.Label11.TabIndex = 3
Me.Label11.Text = "TELEPHONE"
Me.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Form1
'
Me.AutoScaleBaseSize =
New System.Drawing.Size(5, 13)
Me.ClientSize =
New System.Drawing.Size(456, 517)
Me.Controls.Add(
Me.Label1)
Me.Controls.Add(
Me.ADR1)
Me.Controls.Add(
Me.fer)
Me.Controls.Add(
Me.ENT)
Me.Controls.Add(
Me.NOM)
Me.Controls.Add(
Me.ADR2)
Me.Controls.Add(
Me.VIL)
Me.Controls.Add(
Me.PAY)
Me.Controls.Add(
Me.TEL)
Me.Controls.Add(
Me.FAX)
Me.Controls.Add(
Me.EMA)
Me.Controls.Add(
Me.Label2)
Me.Controls.Add(
Me.Label3)
Me.Controls.Add(
Me.Label4)
Me.Controls.Add(
Me.Label5)
Me.Controls.Add(
Me.Label6)
Me.Controls.Add(
Me.Label7)
Me.Controls.Add(
Me.Label10)
Me.Controls.Add(
Me.Label11)
Me.Name = "Form1"
Me.Text = "FOURNISSEURS"
Me.ResumeLayout(
False)
End
Sub#
End
Region
Dim appExcel
As Excel.Application
Dim wbExcel
As Excel.Workbook
Dim MonFichier
As
String
Dim MonXL
As
Object
Dim doc
As
Object
Dim i
As
Integer
Private
Sub Form1_Load(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles
MyBase.LoadMonFichier = "E:\Adresses fournisseurs.xls"
MonXL = CreateObject("Excel.Application")
doc = MonXL.Workbooks.Open(FileName:=MonFichier)
doc.sheets("Liste").activate()
i = 2
Do
Until doc.Worksheets("Liste").Cells(i, 1).value2
Is
NothingENT.Items.Add(doc.Worksheets("Liste").Cells(i, 1).value2)
i = i + 1
Loop
End
Sub
Private
Sub fer_Click(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles fer.Click
'doc.save()doc.close()
End
End
Sub
Private
Sub Form1_Closing(
ByVal eventSender
As System.Object,
ByVal eventArgs
As System.ComponentModel.CancelEventArgs)
Handles
MyBase.Closing
Dim Cancel
AsShort
eventArgs.CancelCancel
TrueeventArgs.Cancel = Cancel
End
Sub
Private
Sub ent_SelectedIndexChanged(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles ENT.SelectedIndexChangedNOM.Text = doc.Worksheets("Liste").Cells(i, 2).value2
ADR1.Text = doc.Worksheets("Liste").Cells(i, 3).value2
ADR2.Text = doc.Worksheets("Liste").Cells(i, 4).value2
VIL.Text = doc.Worksheets("Liste").Cells(i, 5).value2
PAY.Text = doc.Worksheets("Liste").Cells(i, 6).value2
TEL.Text = doc.Worksheets("Liste").Cells(i, 7).value2
FAX.Text = doc.Worksheets("Liste").Cells(i, 8).value2
EMA.Text = doc.Worksheets("Liste").Cells(i, 9).value2
End
SubEnd
Class
Afficher la suite