VB6.0用掲示板の過去のログ(No.1)−VBレスキュー(花ちゃん)
[記事リスト] [新規投稿] [新着記事] [ワード検索] [過去ログ] [管理用]

投稿日: 2004/02/04(Wed) 16:55
投稿者nobu
Eメール
URL
タイトルRe: タイマーで

適当な箇所で改行して下さい。

Sub data() の中で .Add したので次から次に
新しいExcelが開いてしまいます。


差し辺りは下記で如何でしょうか?

------------------------------

Option Explicit

Dim lngCounter As Long
Dim j As Integer
Dim X As Integer
Dim xlBook   As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlApp    As Excel.Application
    
Private Sub Form_Load()
    
    Set xlApp = CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.Add
    Set xlSheet = xlBook.Worksheets.Add

End Sub

Private Sub Command2_Click()

'終了用

    Set xlSheet = Nothing
    Set xlBook = Nothing
    Set xlApp = Nothing

    Unload Me
    
End Sub

Sub data()

    j = 9 + X
    xlSheet.Cells(j, 10) = lngCounter
    X = X + 1
    xlApp.Visible = True

End Sub

Private Sub Command1_Click()
   If Timer1.Interval = 1000 Then
          Timer1.Interval = 0
   Else
        Label1.Caption = ""
        lngCounter = 0
        X = 0
        Timer1.Interval = 1000
    End If

End Sub

Private Sub Timer1_Timer()
      lngCounter = lngCounter + 1
      Label1.Caption = lngCounter
      Call data
End Sub


- 関連一覧ツリー (★ をクリックするとツリー全体を一括表示します)

- 返信フォーム (この記事に返信する場合は下記フォームから投稿して下さい)

- Web Forum -