Excel As Output VB
As us know, VB can process data from various
data format or source, for example data of dBASE, Access,SQL Server, Mysql, and others. Data which have been processed VB
can be in the form of printing;mould use Data
Report, Crystal Report, or the other.
In most cases, consumer of our program wish result
program process ( including also report) kept in the form of
book work Excel. Of course with various reason, for example data
can be worked over or can be printed the parts of just certain.
So, in the reality to result of process of VB into book
work Excel can be conducted enough easy to.
Writing down Data of VB to Excel
Utilize to facilitate to study the way of data of VB to
in spread sheet of Excel, we will study it with
case example. For that conduct stages;steps following 1. Make new project in VB, later;then keep and form
project-nya by the name of Lat5 2. Make some object like Picture 3.1 following.
can be worked over or can be printed the parts of just certain.
So, in the reality to result of process of VB into book
work Excel can be conducted enough easy to.
picture 3.1 Project Lat5Presenting last program code editor make program code
following.
' declaration of variable application object of Excel
Dim Oxl Ace of Excel.Application
Private Sub of Command1_Click()
' variable declaration of memory
Dim Namafile, Area, Month;Moon, Year Ace of String
Dim Kgsemangka, Kgnanas, Kgmangga Ace of Currency
' filling variable with stuffing of form.
On Error Goto Salahinput
Namafile = Text1.Text
Area = Combo1.Text
Month;Moon = Combo2.Text
Year = Combo3.Text
Kgsemangka = Text2.Text
Kgnanas = Text3.Text
Kgmangga = Text4.Text
' making new instance of Excel
Set oXL = New Excel.Application
' enhancing new [job/activity] book
oXL.Workbooks.Add.
' writing down variable of VB to spread sheet of Excel
oXL.Worksheets(1).Range("A1 = " PT. Prosperous Successful Agro"
oXL.Worksheets(1).Range("A2 = " Result of Crop Monthly"
oXL.Worksheets(1).Range("A3 = " Area"
oXL.Worksheets(1).Range("A4 = " Month;Moon"
oXL.Worksheets(1).Range("A5 = " Year"
oXL.Worksheets(1).Range("A6 = " Item"
oXL.Worksheets(1).Range("A8 = " Watermelon"
oXL.Worksheets(1).Range("A9 = " Pineapple"
oXL.Worksheets(1).Range("A10 = " Mango"
oXL.Worksheets(1).Range("B3 = Combo1.Text
oXL.Worksheets(1).Range("B4 = Combo2.Text
oXL.Worksheets(1).Range("B5 = Combo3.Text
oXL.Worksheets(1).Range("B6 = " Amount of"
oXL.Worksheets(1).Range("B7 = " Singk"
oXL.Worksheets(1).Range("B8 = Kgsemangka
oXL.Worksheets(1).Range("B9 = Kgnanas
oXL.Worksheets(1).Range("B10 = KgMangga
' presenting Excel
oXL.Visible = True
Exit Sub
Salahinput:
Msgbox " There [is] mistake of data input!", vbOKOnly
End Sub
Private Sub of Command2_Click()
' closing book work Excel
oXL.Workbooks.Close
End.
Download modul
0 comments on "Excel As Output VB"
Subscribe in a Reader
Post a Comment