アプリ版:「スタンプのみでお礼する」機能のリリースについて

コマンドボタンを押すたびに ココ という文字をテキストボックスに書く。


Private Sub Command1_Click()
Dim i As Integer
i = Int(Rnd * 4)
For c = 0 To 4
Text1(c).Text = ""
Next c


Text1(i).Text = "ココ"
End Sub

VB6ではこんなふうになると思います。
.NETではどう書けばいいのでしょうか?

A 回答 (2件)

.NETでは、コントロール配列が使用できないので以下のようにしてみました。


如何でしょうか。

Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
  Dim t(4) As String
  Dim i As Integer
  Dim c As Integer

  i = Int(Rnd() * 4)

  For c = 0 To 4
    If c = i Then
      t(c) = "ココ"
    Else
      t(c) = ""
    End If
  Next

  Text1.Text = t(0)
  Text2.Text = t(1)
  Text3.Text = t(2)
  Text4.Text = t(3)
  Text5.Text = t(4)
End Sub
    • good
    • 0
この回答へのお礼

ご回答ありがとうございました。

やはりこうするしかないのでしょうか?

お礼日時:2003/05/17 00:18

まだ締め切っていないようなので、別案です。



Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
  Dim t(4) As TextBox
  Dim i As Integer
  Dim c As Integer

  t(0) = Text1
  t(1) = Text2
  t(2) = Text3
  t(3) = Text4
  t(4) = Text5

  i = Int(Rnd() * 4)

  For c = 0 To 4
    If c = i Then
      t(c) = "ココ"
    Else
      t(c) = ""
    End If
  Next
End Sub
    • good
    • 0
この回答へのお礼

2回もの回答ありがとうございます。

しかし不便になりましたね・・・

お礼日時:2003/06/06 00:22

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!