In my previous tutorials, I had discussed about how to have an excel file using vb.net. And for now, we will create a program that can have an excel file from vb6.
Now, let's start this tutorial!
1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open
Microsoft Visual Basic 6.0, click
Choose Standard EXE, and click
Open.
2. Next, add two TextBox named
Text1 and
Text2 for inputting and displaying it in excel. Add also one button named
Command1 for displaying it in an excel file. You must design your interface like this:
3. Now put this code for your code module. This code is for Button1_Click:
Private Sub Command1_Click()
Dim appExcel As Excel.Application
Dim appWB As Excel.Workbook
Dim appWS As Excel.Worksheet
Set appExcel = Excel.Application
appExcel.Visible = True
Set appWB = appExcel.Workbooks.Add
Set appWS = appWB.Worksheets("Sheet1")
appExcel.Sheets("Sheet1").Cells(1, 2).Font.Bold = True
appExcel.Sheets("Sheet1").Cells(1, 2).Font.Name = "Verdana"
appExcel.Sheets("Sheet1").Cells(1, 2).Font.Color = &H80&
appExcel.Sheets("Sheet1").Cells(1, 2).Font.Italic = &H80&
appExcel.Sheets("Sheet1").Cells(1, 1) = Text1.Text
appExcel.Sheets("Sheet1").Cells(1, 2) = Text2.Text
appExcel.Visible = True
End Sub
Explanation:
We have initialized variable
appExcel As Excel.Application,
appWB As Excel.Workbook, and
appWS As Excel.Worksheet. Then we set appExcel to hold an Excel Application, appWB will add an excel workbook of appExcel, and appWS to hold a worksheet out from appWB and named it as Sheet1. Then, the appExcel sheets in sheet1 in cells(rows,columns) of the worksheets and has methods like fonts and its aattributes such as Bold, Name, Color, and Italic. Our Text2 will be our basis that it is bold, in verdana font style, has a font color of a reddish color, and is italic because they have same cells of 1,2.
Output:
Download the source code and try it! :)
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
STI College - Surigao City
Mobile: 09488225971
E-mail:
[email protected]
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at:
https://www.facebook.com/BermzISware