テキストボックスを二つ用意して、一個目に1、二個目に10といれ、リストボックスに1から10までの10個の数字を表示させるにはどうしたらいいですか?
[VB6.0]
Option Explicit
Private Sub Command1_Click()
Dim wStartCnt As Integer
Dim wTempCnt As Integer
Dim wEndCnt As Integer
If ErrChkText(Me.Text1) Then Exit Sub
If ErrChkText(Me.Text2) Then Exit Sub
wStartCnt = CInt(Me.Text1.Text)
wEndCnt = CInt(Me.Text2.Text)
If wStartCnt > wEndCnt Then
wTempCnt = wStartCnt
wStartCnt = wEndCnt
wEndCnt = wTempCnt
End If
With Me.List1
.Clear
For wTempCnt = wStartCnt To wEndCnt
.AddItem CStr(wTempCnt)
Next
End With
End Sub
Private Function ErrChkText(ByVal TextBoxX As TextBox) As Boolean
Dim TextX As String
With TextBoxX
TextX = Trim(.Text)
If Len(TextX) = 0 Then
MsgBox .Name & " を入力して下さい。"
.SetFocus
ErrChkText = True
Exit Function
ElseIf Not IsNumeric(TextX) Then
MsgBox "数値として有効な値を入力して下さい。"
.SetFocus
ErrChkText = True
Exit Function
End If
.Text = CStr(CInt(TextX))
End With
End Function
完璧でした!ありがとうございます。
完璧でした!ありがとうございます。
ツイート | ![]() |