掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
下記のプログラムを直すには? (ID:87613)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
FormにTimer1、Frame1、Command1を配置して Frame1上にPicturebox1(0)、Picturebox1(1)を配置して 下記のプログラムを実行したところ、 表示と非表示を繰り返し行うと PictureboxとLineにズレが生じてきてしまうのですが どこを直したらよいのか教えていただけますか? Option Explicit Const TTT = 80 Dim Pf As String Dim Pr As String Dim n As Integer Private Sub Form_Load() Form1.Width = 10000 Form1.Height = 5850 Frame1.Visible = False Frame1.Width = 8800 Frame1.Height = 3615 Frame1.Top = 800 Frame1.Left = 400 Command1.Top = 300 Command1.Left = 500 Command1.Caption = "表示" End Sub Private Sub Command1_Click() Static OLD_X As Integer Static OLD_Y As Integer If Frame1.Visible = False Then Frame1.Visible = True Timer1.Interval = 100 Timer1.Enabled = True For n = 0 To 1 Picture1(n).Appearance = 0 'picturebox の境界を消す。 Picture1(n).BorderStyle = 0 Picture1(n).Width = TTT * 110 Picture1(n).Height = 2800 Picture1(0).Left = 0 Picture1(n).Top = 300 Picture1(n).BackColor = &HFFC0C0 '背景色設定 SCALE_DRAW n Next Picture1(1).Left = Picture1(0).Left + Picture1(0).Width Command1.Caption = "非表示" Else Timer1.Enabled = False Frame1.Visible = False Form1.Width = 9600 Command1.Caption = "表示" End If End Sub Sub SCALE_DRAW(n) Dim OLD_X As Integer, OLD_Y As Integer Picture1(n).AutoRedraw = True Picture1(n).DrawWidth = 2 Picture1(n).DrawStyle = 0 Picture1(n).ForeColor = &HFF& End Sub Private Sub Timer1_Timer() DRAW End Sub Private Sub DRAW() Dim Y As Integer Static OLD_X As Integer Static OLD_Y As Integer Y = Int(Rnd * 2000) '描画が端に来たらPictureを切り替える If OLD_X > Picture1(0).Width Then If Picture1(0).Left < Picture1(1).Left Then Picture1(0).Left = Picture1(1).Left + Picture1(1).Width Picture1(0).Cls SCALE_DRAW (0) Else Picture1(1).Left = Picture1(0).Left + Picture1(0).Width Picture1(1).Cls SCALE_DRAW (1) End If OLD_X = 0 End If '常に右側のPictureに描画 If Picture1(0).Left < Picture1(1).Left Then If OLD_Y > 0 Then Picture1(1).Line (OLD_X, OLD_Y)-(OLD_X + TTT, Y) Picture1(0).Left = Picture1(0).Left - TTT Picture1(1).Left = Picture1(0).Left + Picture1(0).Width End If Else If OLD_Y > 0 Then Picture1(0).Line (OLD_X, OLD_Y)-(OLD_X + TTT, Y) Picture1(1).Left = Picture1(1).Left - TTT Picture1(0).Left = Picture1(1).Left + Picture1(1).Width End If End If OLD_X = OLD_X + TTT OLD_Y = Y End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.