by Murali (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 29th June 2004
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Create a Temporary file.
Option Explicit
'Creates Temp File
'Add a Command button..command1
'Add a Text box
'Copy and paste the following code.
'====COMMENT END==============
Private Function GetTempName(TmpFilePrefix As String) As String
Dim TempFileName As String * 256
Dim X As Long
Dim DriveName As String
DriveName = "c:\"
X = GetTempFileName(DriveName, TmpFilePrefix, 0, TempFileName)
GetTempName = Left$(TempFileName, InStr(TempFileName, Chr(0)) - 1)
End Function
Private Sub Command1_Click()
Dim FilePrefix As String
Dim NewFile As String * 256
FilePrefix = "TEST"
NewFile = GetTempName(FilePrefix)
Text1.Text = NewFile
End Sub