oh... i m so sorry...
yeah that codes for vb 6, but there are same code for vb.net.
this following code for vb.net.
Dim MsExcel As Excel.Application
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsExcel = CreateObject("Excel.Application")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With ListBox1.Items
.Add(txtName.Text)
.Add(txtEmail.Text)
.Add(txtMobile.Text)
End With
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsExcel.Workbooks.Add()
MsExcel.Range("A1").Value = txtName.Text
MsExcel.Range("B1").Value = txtEmail.Text
MsExcel.Range("C1").Value = txtMobile.Text
MsExcel.Visible = True
End Sub
- button 1 for add item from textbox to listbox.
- button 2 to add all item in listbox to excel.
- Declare Dim MsExcel As Excel.Application in top of all event. don't declare it on event cause it be a global variable.
- You can modified it as u needed.
Last edited by Jx_Man : May 11th, 2008 at 5:32 am.