31/07/11 23:04
eurostar_italia
vb6 - esecuzione loop con tasto command
Salve a tutti,
nuovo quesito in arrivo.
sto creando un piccolo programmino in vb,che importa i dati da un foglio excel,legge le relative righe (finchè sono piene,con un ciclo do loop) e inserisce i valori in delle variabili.tutto questo sul form 1 a questo punto passa i valori a delle txtbox sul form2.
l'obiettivo finale è stampare queste txt box.
ora vorrei iniziare il ciclo di lettura righe e di passaggio dati al form2 ma prima di continuare con la lettura delle altre righe,vorrei che l'utente prema un tasto command della form2.
secondo voi è possibile ?
aggiungo il codice che ho scritto
Private Sub Command1_Click() Set statoexcel = New Excel.Application statoexcel.Visible = False nomefile = statoexcel.GetOpenFilename End Sub Private Sub Command2_Click() Set statoworkbook = statoexcel.Workbooks.Open(nomefile) Set statosheet = statoworkbook.Worksheets(1) If IsNumeric(statosheet.Cells(4, 1)) = True Then treno = statosheet.Cells(4, 1) MsgBox ("Caricato treno : " & treno) i = 4 Do While statosheet.Cells(i, 1) <> "" nominativo = statosheet.Cells(i, 4) destinazione = statosheet.Cells(i, 2) pnr = statosheet.Cells(i, 3) marca = statosheet.Cells(i, 5) targa = statosheet.Cells(i, 7) treno = statosheet.Cells(i, 1) tipo = statosheet.Cells(i, 6) data = statosheet.Cells(2, 3) If tipo = 0 Then Form2.txt_veicolo = "auto" Else: Form2.txt_veicolo = "moto" End If Form2.txt_nominativo = nominativo Form2.txt_destinazione = destinazione Form2.txt_marca = marca Form2.txt_pnr = pnr Form2.txt_targa = targa Form2.txt_treno = treno Form2.txt_data = data Form2.Show i = i + 1 Loop Else MsgBox "errore,non è un numero valido" End If End Sub
aaa