Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > [VB] Aiuto
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
thecrow
Non Può Piovere X Sempre

User info:
Registered: Jan 2002
Posts: 272 (0.03 al dì)
Location: Milano
Corso: Informatica
Anno:
Time Online: 2 Days, 2:49:51 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Aiuto Visual Basic Urgente!!!

Ragazzi ho bisogno di un grosso aiuto!
Partendo da una casella di testo e da un bottone,cliccando su quest'ulitmo deve partire una routine che accoda in un file di testo il contenuto della casella.
Su internet ho trovato questo codice:

Private Sub cmdScriviTesto_OnClick()
Dim cartella As String, documento As String, FileNumber As Integer

cartella = "E:\Infopath"; (cartella dove metto il file)
documento = cartella & "prova.txt"; (percorso e nome del file che creo)
FileNumber = FreeFile

Open documento For Output As #FileNumber ' Crea un nome di file e se già esiste lo sovrascrive

testo = domanda1.Text 'assegna alla variabile il contenuto della textbox che contiene il testo

Print #FileNumber, testo ' Scrive il testo nel file

Close #FileNumber ' Chiude il file.
End Sub


PS:

cmdScriviTesto=nome del bottone
domanda1=nome casella di testo


Allora,io sto usando infopath,cliccando sul bottone e dicendo che vuoi usare uno script lui ti apre microsoft script,incollando questo codice mi da un errore nella riga della dichiarazione variabili dicendo PREVISTA FINE ISTRUZIONI,ho provato ad aggiungere dei ; ma nn serve a niente

invece se creo tt questo proprio in visual basic express mi da errore in "Open documento..."dicendo che i metodi devono essere dichiarati nelle parentesi???

boh nn ci capisco piu niente!!!

qualcuno puo dirmi se secondo lui quel codice è giusto o se ci sono modifiche da fare?

GRAZIE MILE è URGENTISSIMO!!!

__________________
Guardate il mio post su Feedback prima di comprare qualcosa
http://www.dsy.it/forum/showthread.php?s=73a12d5e23c34b3478161c4007fc11b2&threadid=13647&pagenumber=1

Last edited by thecrow on 17-06-2005 at 15:33

17-06-2005 15:30
Click Here to See the Profile for thecrow Click here to Send thecrow a Private Message Find more posts by thecrow Add thecrow to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
thecrow
Non Può Piovere X Sempre

User info:
Registered: Jan 2002
Posts: 272 (0.03 al dì)
Location: Milano
Corso: Informatica
Anno:
Time Online: 2 Days, 2:49:51 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

dimenticavo sotto documento =... c'è:
FileNumber = FreeFile
sul sito c'è scritto che Per poter aprire e gestire un file , a Visual Basic non serve tanto il suo nome logico ("prova.txt" in questo caso) quanto un numero che lo identifichi univocamente , diverso per ogni file del programma. Almeno finchè non chiudiamo il file con l'istruzione Close. A quel punto il numero ritorna libero per poter essere utilizzato con un altro file.

comunque anche togliendo l'errore è sempre quello

__________________
Guardate il mio post su Feedback prima di comprare qualcosa
http://www.dsy.it/forum/showthread.php?s=73a12d5e23c34b3478161c4007fc11b2&threadid=13647&pagenumber=1

17-06-2005 15:32
Click Here to See the Profile for thecrow Click here to Send thecrow a Private Message Find more posts by thecrow Add thecrow to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
VdM
.simpatizzante.

User info:
Registered: Jan 2003
Posts: 9 (0.00 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 1 Day, 15:07:06: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ciao, ho fatto una prova in VB6 basata sul tuo codice (stessi nomi di variabili e di controlli), utilizzando qualche semplificazione, e non vengono sollevati errori. Posto il codice (commentato ove necessario) che ho testato:

[code begins]

Private Sub cmdScriviTesto_Click()
Dim cartella As String, documento As String, FileNumber As Integer

'Nel mio esempio, utilizzo la directory corrente del processo,
'identificata da App.Path
'Dunque commento i seguenti:
'cartella = "E:\Infopath" '(cartella dove metto il file)
'documento = cartella & "prova.txt" '(percorso e nome del file che creo)

'nome del documento nella directory corrente
documento = App.Path & "\prova.txt"

'Nell'esempio assegno l'identificatore #1 al file da aprire,
'senza cercare un identificatore libero mediante FreeFile

'FileNumber = FreeFile

'Apro il documento in modalita' Append. Cio' permette l'accodamento dei dati al file
Open documento For Append As #1 ' Crea un nome di file e se già esiste lo sovrascrive

testo = domanda1.Text 'assegna alla variabile il contenuto della textbox che contiene il testo

Print #1, testo ' Scrive il testo nel file

Close #1 ' Chiude il file.
End Sub

[code ends]

L'unica cosa che avevo notato e' il fatto che c'era scritto qualche commento senza l'apice, per il resto il codice a me funge...
Che versione di VB utilizzi?

Saluti,

VdM

17-06-2005 16:58
Click Here to See the Profile for VdM Click here to Send VdM a Private Message Find more posts by VdM Add VdM to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
thecrow
Non Può Piovere X Sempre

User info:
Registered: Jan 2002
Posts: 272 (0.03 al dì)
Location: Milano
Corso: Informatica
Anno:
Time Online: 2 Days, 2:49:51 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

mmmh...ora riguardo un po allora,grazie mille!!!

__________________
Guardate il mio post su Feedback prima di comprare qualcosa
http://www.dsy.it/forum/showthread.php?s=73a12d5e23c34b3478161c4007fc11b2&threadid=13647&pagenumber=1

17-06-2005 17:50
Click Here to See the Profile for thecrow Click here to Send thecrow a Private Message Find more posts by thecrow Add thecrow to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 00:43.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.056 seconds (54.22% PHP - 45.78% MySQL) con 22 query.