16/08/08 12:44
gouap
Salve a tutti..Sono un neofita programmatore e vorrei saper e se qualcuno mi sa dire come posso fare in modo che in vb6 il programma verifichi la presenza di un drive e se esiste ci scriva, cioè:
Se C:\ esiste allora
apri C:\ & ("\Data.txt"
per scrivere #1
Io ho provato Così e non funziona..
Private Sub Command1_Click()
Dim Drive1 As Object
Drive1 = "A:\"
If Drive1.Exists = True Then
Open "A:\" & ("\Data.txt"
For Output As #1
End If
aiutatemi è importante..
Ultima modifica effettuata da Shutdown 18/08/08 0:12
aaa
16/08/08 14:29
Overflow
potresti usare il controllo DriveListBox, oppure usare l'oggetto filesystemobject(Scripting.FileSystemObject) o usare anche le api di windows, ad esempio:
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
Dim drvtmp As String
Dim drives() As String
Dim res As Long
Dim lnstr As Integer
res = GetLogicalDriveStrings(0, drvtmp)
drvtmp = String(res, 0)
lnstr = res
res = GetLogicalDriveStrings(lnstr, drvtmp)
drvtmp = Trim(drvtmp)
drvtmp = Replace(drvtmp, vbNullChar, "-")
drvtmp = Replace(drvtmp, "-", "-")
drives = Split(drvtmp, "-")
End Sub
a questo punto ottieni l'array drives che contiene le lettere dei drive.
Ultima modifica effettuata da Overflow 16/08/08 14:30
aaa
16/08/08 15:03
Alceus
Mettete titoli più significativi... Anche se si tratta di qualcosa di importante ogni richiesta ha la stessa priorità... Il moderatore deve gestire anche altri forum, quindi non può badare ad ogni topic...
Ultima modifica effettuata da Alceus 16/08/08 15:04
aaa
20/08/08 9:10
prova a mettere "a:\data.txt"