Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11

Discussione: [VB6]creare finestre

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    92

    [VB6]creare finestre

    Raga, sto cercando di creare un prog. ke quando chiudi una finestra se ne aprono 2 e poi 4, 8, 16, 32 insomma in maniera esponenziale..
    Per l'interfaccia grafica nn ci sono problemi, ma come codice ke devo mettere, ho pensato di fare un ciclo for es:
    codice:
    For a = 1 To 10
        MsgBox "ciao"
    Next a
    ma ne esce solo una alla volta e dopo ke ho kiuso la precedente...
    Nn so + come fare fatemi un pò capire...
    thx mille
    Bye

    Peppe...
    La domanda è sempre Come...

  2. #2
    Non lo puoi fare con le MSGBOX perchè VB aspetta che ne chiudi una prima di continuare a scorrere il codice, devi crerne una tua e poi potrai dirgli

    For a = 1 to 100
    frmmodal.show
    Next

    Oppure la crei a runtime.

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    92
    devi crerne una tua e poi potrai dirgli

    For a = 1 to 100
    frmmodal.show
    Next
    Cioè dici ke dovrei creare un 'altra form?? e poi fare il ciclo for?? scusa frmmodal.show ke significa??

    Oppure la crei a runtime.
    Cioè??

    Scusa ma so nna pippa... mi spiegheresti meglio pls??

    Thx

    Peppe
    La domanda è sempre Come...

  4. #4
    Guarda ci sto provando appena trovo il codice te lo posto


  5. #5
    Dichiarazioni

    codice:
    Private m_bNumericOnly As Boolean
    Private m_oForm As Form
    Private m_oLbl As Label
    'WithEvents allows you to capture events
    'in code-generated form
    Private WithEvents m_oOKBtn As CommandButton
    Private WithEvents m_oCancelBtn As CommandButton
    Private WithEvents m_oInput As TextBox
    Routine che crea il Form

    codice:
    Private Sub GenerateForm()
    
    
    Dim oCtl As Control
    Set m_oForm = New Form1
    
    'Clean previous instances
    'of controls, if any.
    'otherwise, GPF occurs
    'after awhile
    
    Set m_oOKBtn = Nothing
    Set m_oCancelBtn = Nothing
    Set m_oInput = Nothing
    Set m_oLbl = Nothing
    
    'clear the form
    For Each oCtl In m_oForm
        oCtl.Visible = False
    Next
    
    Set m_oOKBtn = m_oForm.Controls.Add("VB.CommandButton", "cmdOK")
    Set m_oCancelBtn = m_oForm.Controls.Add("VB.CommandButton", "cmdCancel")
    Set m_oInput = m_oForm.Controls.Add("VB.TextBox", "txtInput")
    Set m_oLbl = m_oForm.Controls.Add("VB.Label", "lblInst")
    
    With m_oForm
        'Set form's width and height
        .Width = 4000
        .Height = 2500
        .Caption = "This form was generated by VB Code only"
            
    
    End With
    
    'Setup rest of controls
    
    With m_oLbl
        .Top = 250
        .Left = 250
        .AutoSize = True
        .FontBold = True
        .Caption = IIf(m_bNumericOnly, "Enter Your Age:", "Enter Your Last Name:")
        
    End With
    
    With m_oInput
        .Top = m_oLbl.Top + m_oLbl.Height + 250
        .Left = 250
        
        .Height = 295
        If m_bNumericOnly Then
            .Width = 500
            .MaxLength = 3
        Else
            .Width = 2500
        End If
    End With
    
    With m_oOKBtn
        .Top = m_oInput.Top + m_oInput.Height + 375
        .Width = 800
        .Left = 1000
        .Height = cmdGenerate(0).Height
        m_oOKBtn.Caption = "&OK"
        .Enabled = False
    End With
    
    With m_oCancelBtn
        .Left = m_oOKBtn.Left + m_oOKBtn.Width + 100
        .Top = m_oOKBtn.Top
        .Width = m_oOKBtn.Width
        .Height = m_oOKBtn.Height
        .Caption = "&Cancel"
    End With
    
    
    m_oOKBtn.Visible = True
    m_oCancelBtn.Visible = True
    m_oLbl.Visible = True
    m_oInput.Visible = True
    m_oForm.Show vbModal
    
    End Sub

    Buon divertimento !!

    Chiaramente il codice va pulito perchè in questa Call
    ti aggiunge anche un inputbox e altro ancora ...

  6. #6
    te l' ho pulito io

    Command

    codice:
    Private Sub Command1_Click()
    Dim x As Integer
        For x = 1 To 100
        Call GenerateForm(x * 2)
        Next
    End Sub

    Routine

    codice:
    Private Sub GenerateForm(x As Integer)
    
    
    Set m_oForm = New Form1
    With m_oForm
        'Set form's width and height
        .Width = 4000
        .Height = 2500
        .Top = 100 + x
        .Caption = "This form was generated by VB Code only"
    End With
    m_oForm.Show
    End Sub
    Lavorandoci la si puo' migliorare ancora di piu'

    :-)

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    92
    Mitico Raffaeu...

    Avevo difficoltà a capire il primo codice ke avevi postato , poi fortunatamente l'hai pulito tu... thx mille...

    Il command l'ho capito, x la routine invece c'è qlke prob. nn credo di averla capita bene...

    codice:
    Private Sub GenerateForm(x As Integer)
    
    
    Set m_oForm = New Form1
    With m_oForm
        'Set form's width and height
        .Width = 4000
        .Height = 2500
        .Top = 100 + x
        .Caption = "This form was generated by VB Code only"
    End With
    m_oForm.Show
    End Sub
    Correggimi se sbaglio:

    Riga 1: crea una nuova Form;
    2)Il Whit sarebbe un ciclo??
    3-4-5)setta la larghezza e l'altezza della finestra;
    6)???
    7)il titolo della finestra;
    Giusto??
    Ps. dove l'hai preso il primo codice??

    Thx di tutto...


    Peppe
    La domanda è sempre Come...

  8. #8
    MSDN ...

    Il With serve per non scrivere 100 volte le stesse cose

    Esempio :

    codice:
    ...........................
    Form.Caption = "Form"
    Form.Width = 100
    ...........................
    With Form
         .Caption = "Form"
         .Width = 100
    End With
    ...........................
    Ok? Un buon sito ?

    http://www.freevbcode.com/
    Classi, Moduli, OCX free, tutorial e quant' altro per VB6, .NET e ASP3


  9. #9
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    92
    Grazie di tutto...
    La domanda è sempre Come...

  10. #10
    Utente di HTML.it L'avatar di cassano
    Registrato dal
    Aug 2004
    Messaggi
    3,002
    lo visto carina , per caso sai anche dove trovare librerie aggiuntiver per il vb6 o il vb.net anche a pagamento ????

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.