Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [VB6] loop su opt non va +

    Ciao avevo creato un loop su delle opt presenti in un form ma ora non va piu', non funziona il ciclo

    codice:
    Private Sub controllaOpt()
    On Error Resume Next
    Dim opt As OptionButton
    Dim frm As Form
    Set frm = frmRegistrazione
        For Each opt In frm
            If opt.Value = True Then
                Select Case opt.Tag
                    Case "A": caricaAlbero
                    Case "B":
                                If txtDATA.Text = "" Or txtDATA2.Text = "" Then
                                    MsgBox "Inserire entrambe le date."
                                    txtDATA.SetFocus
                                    Exit Sub
                                Else
                                    Dim dDate As String
                                    Dim aDate As String
                                    If Not IsDate(Trim(txtDATA)) Then txtDATA = Format(Date, "dd" & sDate & "mm" & sDate & "yyyy")
                                    If Not IsDate(Trim(txtDATA2)) Then txtDATA2 = Format(Date, "dd" & sDate & "mm" & sDate & "yyyy")
                                    dDate = Format(txtDATA, "mm/dd/yy")
                                    dDate = Replace(dDate, ".", "/")
                                    aDate = DateAdd("d", 1, CDate(txtDATA2))
                                    aDate = Format(aDate, "mm/dd/yy")
                                    aDate = Replace(aDate, ".", "/")
                                    RICERCA "DataModifica Between #" & dDate & "# And #" & aDate & "# "
                                End If
                    Case "C":
                                If txtCLIENTE.Text = "" Then
                                    MsgBox "Scegliere un Cliente / Fornitore"
                                    txtCLIENTE.SetFocus
                                    Exit Sub
                                Else
                                    RICERCA "CLIENTE = " & lblID_CLIENTE.Caption
                                End If
                    Case "D":
                                If txtFATTURA.Text = "" Then
                                    MsgBox "Inserire un numero da ricercare."
                                    txtFATTURA.SetFocus
                                    Exit Sub
                                Else
                                    RICERCA "FATTURA = " & txtFATTURA.Text
                                End If
                End Select
            End If
        Next
    End Sub
    In grassetto la parte incriminata, se vado in debug, quando sono nel ciclo mi dice variabile ... non impostata ed esce, perchè?

  2. #2

    up

    up

    secondo voi cosa puo' essere

  3. #3
    dovresti cambiare un po il ciclo, cercando controlli generici (non solo option e al limite confrontando il tipo (TypeName). Poi il ciclo va fatto sull'insime controls del form:
    codice:
    Dim opt As Control
    Dim frm As Form
    Set frm = frmRegistrazione
    For Each opt In frm.Controls
       If TypeName(opt) = "OptionButton" Then 
            If opt.Value = True Then
                Select Case opt.Tag
                    Case "A": caricaAlbero
                    Case "B":
                    ...
                End Select
            End If
       end if
    Next opt

  4. #4
    non so se va bene lo stesso, ma ho risolto in questo modo:

    codice:
    Dim opt As OptionButton
        For Each opt In frmRegistrazione
            If opt.Value = True Then
                Select Case opt.Tag
    
    ... ... ... ... ... ... ... ... ... ...
     ... ... ... ... .... ... .. .. .. . . .. .
    Adesso funziona, prima non so come mai ma non trovava l' oggetto opt quando il ciclo arrivava sulla riga opt.tag, adesso la trova ???

    Boh ...

    PS: un buon sito dove scaricare qualche ocx bello, tipo list view con immagini e simili?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.