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

投稿日: 2002/12/05(Thu) 01:05
投稿者yoshi
URL
タイトルRe^8: VBでエクセルを閉じる時・・・

> その都度残っている Excelを終了していますか?
その都度終了しています。

以下のようにしたのですが、shousaiではオブジェクトの代入や解放は必要ないと考えてよいのでしょうか?

Private Sub seireki_Change()
    Set xlApp = CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\吉原昌也\デスクトップ\システ  ム")
    Set Spara = xlBook.Worksheets("パラ")
    Set Skekka = xlBook.Worksheets("結果")
    Set Sjinkou_m = xlBook.Worksheets("人口男")
    Set Sjinkou_f = xlBook.Worksheets("人口女")
    Set Skiso_m = xlBook.Worksheets("基礎男")
    Set Skiso_f = xlBook.Worksheets("基礎女")
    Set Skuriagari_m = xlBook.Worksheets("男層繰り上がり")
    Set Skuriagari_f = xlBook.Worksheets("女層繰り上がり")
    Set Shyouka = xlBook.Worksheets("評価2")

    Spara.Range("D29").Value = seireki.Text
    Call shousai

    
    xlApp.DisplayAlerts = False
    xlApp.SaveWorkspace ("システム")
    xlApp.Quit
    Set Spara = Nothing
    Set Skekka = Nothing
    Set Sjinkou_m = Nothing
    Set Sjinkou_f = Nothing
    Set Skiso_m = Nothing
    Set Skiso_f = Nothing
    Set Skuriagari_m = Nothing
    Set Skuriagari_f = Nothing
    Set Shyouka = Nothing
    Set xlBook = Nothing
    Set xlApp = Nothing

End Sub

Public Sub shousai()
    detail.AutoRedraw = True
        detail1.AutoRedraw = True
        detail.Cls   'Line(0, 0) - Step(1500, 1500), RGB(255, 255, 255), BF
        detail1.Cls   'Line(0, 0) - Step(1500, 1500), RGB(255, 255, 255), BF
        If bunpu.Text = "コーホート人口" Then
            For a = 0 To 10                                 '現在のデータの代入
                pira.p_m(a) = Skekka.Cells(1, 112 + a).Value
                pira.p_f(a) = Skekka.Cells(2, 112 + a).Value
                pira1.p_m(a) = Skekka.Cells(1, 124 + a).Value
                pira1.p_f(a) = Skekka.Cells(2, 124 + a).Value
            Next a
            
            
            For B = 0 To 10                                 '人口ピラミッドの描画
                detail.Line (765, 135 + 133 * B)-Step(pira.p_m(10 - B) / 2, -100), RGB(220 -         B * 6, 220, 220), BF
                detail.Line (735, 135 + 133 * B)-Step(-(pira.p_f(10 - B) / 2), -100), RGB          (220 - B * 6, B * 6, 20 + B * 6), BF
                detail1.Line (765, 135 + 133 * B)-Step(pira1.p_m(10 - B) / 2, -100), RGB(220 -         B * 6, 220, 220), BF
                detail1.Line (735, 135 + 133 * B)-Step(-(pira1.p_f(10 - B) / 2), -100), RGB         (220 - B * 6, B * 6, 20 + B * 6), BF
            Next B
            
            
        End If
                    
        If bunpu.Text = "年少人口" Then
            san(0).p_n = Skekka.Range("DH15").Value
            san(1).p_n = Skekka.Range("DH17").Value
            detail.Line (750 - san(0).p_n / 2, 750 - san(0).p_n / 2)-Step(san(0).p_n, san        (0).p_n), RGB(153, 204, 51), BF
            detail1.Line (750 - san(1).p_n / 2, 750 - san(1).p_n / 2)-Step(san(1).p_n, san        (1).p_n), RGB(153, 204, 51), BF
        End If
        If bunpu.Text = "生産年齢人口" Then
            san(0).p_s = Skekka.Range("DI15").Value
            san(1).p_s = Skekka.Range("DI17").Value
            detail.Line (750 - san(0).p_s / 2, 750 - san(0).p_s / 2)-Step(san(0).p_s, san        (0).p_s), RGB(153, 204, 51), BF
            detail1.Line (750 - san(1).p_s / 2, 750 - san(1).p_s / 2)-Step(san(1).p_s, san        (1).p_s), RGB(153, 204, 51), BF
        End If
        If bunpu.Text = "老年人口" Then
            san(0).p_r = Skekka.Range("DJ15").Value
            san(1).p_r = Skekka.Range("DJ17").Value
            detail.Line (750 - san(0).p_r / 2, 750 - san(0).p_r / 2)-Step(san(0).p_r, san        (0).p_r), RGB(153, 204, 51), BF
            detail1.Line (750 - san(1).p_r / 2, 750 - san(1).p_r / 2)-Step(san(1).p_r, san        (1).p_r), RGB(153, 204, 51), BF
        End If
        detail.AutoRedraw = False
        detail1.AutoRedraw = False
    
End Sub


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

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

- Web Forum -