2
이벤트 처리기 (클릭)에서 변수 j (로컬)를 인식하는 프로그램을 가져올 수 없습니다. check.Value = MyCheck & j.Value
행에 도달하면 루프에 있더라도 'Mycheck1'만 반환합니다.이벤트 처리기에서 인식 할 수없는 변수
모든 체크 버튼을 살펴보고 선택되어 있는지 확인하는 프로그램이 필요합니다. 누구나 올바른 구문을 알고 있습니까?
홈페이지 하위 :
With TempForm.CodeModule
' ** Add/change next 5 lines' This code adds the commands/event handlers
' to the form
X = .CountOfLines
.InsertLines X + 1, "Sub CommandButton1_Click()"
.InsertLines X + 2, "Dim rs As ADODB.Recordset"
.InsertLines X + 3, "Dim rst As ADODB.Recordset"
.InsertLines X + 4, "Dim i As Integer"
.InsertLines X + 5, "Dim ran as string"
.InsertLines X + 6, "j = 1 "
.InsertLines X + 7, "set rs = Rsfun"
.InsertLines X + 8, "Do While Not rs.EOF"
'.InsertLines X + 8, "For j = " & i & " To rs.MaxRecords"
'.InsertLines X + 9, "" & i & " = " & i & " +1"
.InsertLines X + 9, "Dim check As MSForms.CheckBox "
.InsertLines X + 10, "Set check = UserForm1.Controls.Add(""Forms.checkbox.1"")"
.InsertLines X + 11, "check = MyCheck & j"
.InsertLines X + 12, "If Check.value = true then"
.InsertLines X + 13, "ran = ""A" & i & ""
.InsertLines X + 14, "MsgBox (ran)"
.InsertLines X + 15, "range(ran).value= rs.Fields(0)"
.InsertLines X + 16, "End If"
.InsertLines X + 17, "RS.MoveNext"
.InsertLines X + 18, "j= j+1"
.InsertLines X + 19, "Loop"
.InsertLines X + 20, "Unload Me"
.InsertLines X + 21, "End Sub"
End With
이벤트 핸들러 :
Sub CommandButton1_Click()
Dim rs As ADODB.Recordset
Dim rst As ADODB.Recordset
Dim j As Integer
Dim ran As String
j = 1
Set rs = Rsfun
Do While Not rs.EOF
Dim check As MSForms.CheckBox
Set check = UserForm1.Controls.Add("Forms.checkbox.1")
check.Value = MyCheck & j.Value
If check.Value = True Then
ran = "A1"
MsgBox (ran)
range(ran).Value = rs.Fields(0)
End If
j = j + 1
rs.MoveNext
Loop
Unload Me
End Sub
그리고'j'는 무엇을 사용하고 있습니까? 오류가 무엇입니까? 어떻게 알았지? 인식되지 않니? – shahkalpesh
프로그램이 모든 체크 버튼을 버리고 선택되었는지 확인하는 것은 내가 아는 것입니다. 이제 프로그램은 첫 번째 검사 버튼 (MyCheck1) 만 사용하여 검사하며 어떤 이유로 든 나머지 검사를 계속하지 않습니다. – jay
레코드 세트'rs'는 레코드를 어디에서 가져 옵니까? 코드를 보면 일부 소스에서 데이터를 가져올 부분이 없습니다. – shahkalpesh