掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
テキストを左から流して表示するには? (ID:121249)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
このような動きでしょうか? VB.NETで作りました。 ちょっと長いですが・・・ 'Labelに表示する文字を格納する変数 Dim MoziString(3) As String 'コントロールを定義 Dim timer1 As Timer Dim flg As Boolean 'カウント Dim count As Integer, place As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '初期化 count = 1 place = 0 flg = True 'インスタンスを設定 timer1 = New Timer timer2 = New Timer 'パラメータの設定 With timer1 .Interval = 100 End With With timer2 .Interval = 1000 End With 'Labelの設定 With Label1 '各パラメータを設定 Dim kankaku As Integer Dim height As Integer kankaku = 20 height = 40 'テキストを初期化 .Text = "" 'X、Y座標を設定 .Location = New Point(kankaku, Me.Height - (kankaku * 2 + height)) .Size = New Size(Me.Width - (kankaku * 2), height) '背景色の変更 .BackColor = Color.FromArgb(128, 0, 0, 255) '文字色の設定 .ForeColor = Color.FromArgb(255, 255, 255) End With 'イベントハンドラーの作成 AddHandler timer1.Tick, AddressOf timer1_Tick 'Labelに表示される文字の設定 MoziString(0) = "あいうえお" MoziString(1) = "かきくけこ" MoziString(2) = "さしすせそ" 'TimerをStart timer1.Start() End Sub Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Labelに文字を表示 If flg Then Label1.Text &= GetChar(MoziString(place), count) If count >= MoziString(place).Length Then count = 0 place += 1 flg = False End If If place >= UBound(MoziString) Then Label1.Text &= vbCrLf & "Finish" timer1.Stop() End If count += 1 End If End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing 'イベントハンドラーの破棄 'コントロールの破棄 timer1.Dispose() timer2.Dispose() End Sub Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = Keys.Enter Then flg = True Label1.Text &= vbCrLf timer1.Start() End If End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.