Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di ZeroOne
    Registrato dal
    Feb 2002
    Messaggi
    110

    [VB6] Dichiarazione array e riempimento

    salve
    devo fare un programa che apra un file txt in scrittura, legga le 10 righe al suo interno già presenti, salvi il contenuto in un array e poi eventualmente faccia modifiche ai valori e poi salvi il tutto.
    ho fatto praticamente tutto tranne il savaltaggio dei valori in un array.
    sto seguendo svariate guide ma non riesco a far funzionare la dichiarazione dell'array e il relativo riempimento.
    sapreste aiutarmi?
    grazie
    saluti
    It's show time!

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,466

    Moderazione

    Ho spostato la discussione all'interno del forum dedicato a Visual Basic (VBx, VBA, ...) e ai linguaggi per .NET Framework (VB.NET, C#, ...).

    In futuro, poni in questo forum le domande relative a questi linguaggi.

    Ciao!
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  3. #3
    Utente di HTML.it L'avatar di yyzyyz
    Registrato dal
    Oct 2001
    Messaggi
    1,653
    esempio di array a 4 righe(open/update)
    codice:
    Dim nomefile As String
    Dim txt(0 To 3) As String
    
    Private Sub Command1_Click()
    Text1.Text = ""
    
    CommonDialog1.ShowOpen
    nomefile = CommonDialog1.FileName
    
    ' apre il file
    Open nomefile For Input As #1
    Do While Not EOF(1)
        For i = 0 To 3
            Input #1, txt(i)
            Text1.Text = Text1.Text & txt(i) & vbCrLf
            myarray(i).Text = txt(i)
        Next
    Loop
    Close #1
    End Sub
    
    Private Sub Command2_Click()
    ' salva il file
    Text1.Text = ""
    Open nomefile For Output As #1
    For i = 0 To 3
        txt(i) = myarray(i).Text
        Print #1, txt(i) & vbLf
        Text1.Text = Text1.Text & txt(i) & vbCrLf
    Next i
    Close #1
    End Sub
    
    Private Sub Form_Load()
    Reset
    End Sub

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.