LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Is VBA Class have Constructor like java ?

Is VBA Class have Constructor like java ? I want New a clsStatement run
Init_ME() or other Init_xxx ? Is it possible ?


Option Explicit

Public StatementContent As New clsStatement

Sub Start()
With StatementContent
StatementContent.FileNameSource = "g:\ass\ass_statement.txt"
.Read_file
End With

End Sub


'~~ Class Modules

Option Explicit
Public FileNameSource As String ' Statement file name
Const TEMPLATE_DIRECTORY = "g:\ass\"
Const TEMPLATE_NAME = "eStatement_template.xls"
Const STATEMENT_DIR = "g:\ass\Statements"
Private Debtor_FN As String
Private Details(1024) As String
Private Debtor_nbr_pos As Long
Private Debtor_mail_pos As Long

Public Sub Init_ME()

End Sub

Private Sub Init_pos()
Debtor_nbr_pos = 0
Debtor_mail_pos = 0
Debtor_FN = ""
End Sub


Public Sub Build_file()
Dim cnt As Long
Dim Act As Long
Dim loSheet As Variant

'MsgBox VBA.Str(Debtor_nbr_pos)

'~~ Open template file
Workbooks.Open FileName:=TEMPLATE_DIRECTORY + "\" + TEMPLATE_NAME
Workbooks(TEMPLATE_NAME).Activate
Application.Workbooks(TEMPLATE_NAME).SaveAs STATEMENT_DIR + "\" +
Debtor_FN

' Workbooks("new.xls").Activate
Set loSheet = Application.Workbooks(Debtor_FN).Sheets("Statement ")
Act = 6
For cnt = Debtor_nbr_pos To Debtor_mail_pos
loSheet.Cells(Act, 1).Value = Details(cnt)
Act = Act + 1
Next
Application.Workbooks(Debtor_FN).Save
Application.Workbooks(Debtor_FN).Close
Call Init_pos
End Sub

Public Sub Read_file()
Dim fileNumber As Long
Dim cnt As Long
Dim inputVal As String

Call Init_pos

fileNumber = FreeFile ' get unused file number
Application.StatusBar = "Reading ...." & FileNameSource


Open FileNameSource For Input As #fileNumber
Do While Not EOF(fileNumber)
Line Input #fileNumber, inputVal
cnt = cnt + 1
Details(cnt) = inputVal
If VBA.Left(inputVal, 10) = "Debtor nr:" Then
' MsgBox inputVal + " " + VBA.Str(cnt)
Debtor_nbr_pos = cnt
Debtor_FN = VBA.Trim(VBA.Mid(inputVal, 11,
VBA.Len(VBA.Trim(inputVal)) - 10) + ".xls")
'MsgBox Debtor_FN
End If
If VBA.Left(inputVal, 8) = "E-mail :" Then
'MsgBox inputVal + " " + VBA.Str(cnt)
Debtor_mail_pos = cnt
End If
If Debtor_mail_pos < 0 Then
Call Build_file
End If
Loop
Close #fileNumber
MsgBox cnt

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
java to vba PST Excel Discussion (Misc queries) 4 May 10th 07 11:15 PM
Class programming - how to return chartobject from a class? [email protected] Excel Programming 3 October 11th 06 12:07 PM
Class modules: parametrize class object fields Jean-Pierre Bidon Excel Programming 11 August 31st 06 02:49 PM
Little bit of Java in VB? Soulblade Excel Programming 2 August 30th 04 02:39 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM


All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"