home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ivbsrc / temp.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  3.1 KB  |  104 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Test Temp functions"
  4.    ClientHeight    =   2925
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   5085
  8.    Height          =   3330
  9.    Left            =   1035
  10.    LinkMode        =   1  'Source
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   2925
  13.    ScaleWidth      =   5085
  14.    Top             =   1140
  15.    Width           =   5205
  16.    Begin TextBox Text3 
  17.       Height          =   495
  18.       Left            =   1680
  19.       TabIndex        =   5
  20.       Text            =   "Text3"
  21.       Top             =   1920
  22.       Width           =   3015
  23.    End
  24.    Begin CommandButton Command3 
  25.       Caption         =   "Environ$"
  26.       Height          =   495
  27.       Left            =   240
  28.       TabIndex        =   4
  29.       Top             =   1920
  30.       Width           =   1215
  31.    End
  32.    Begin TextBox Text2 
  33.       Height          =   495
  34.       Left            =   1680
  35.       TabIndex        =   3
  36.       Text            =   "Text2"
  37.       Top             =   1200
  38.       Width           =   3015
  39.    End
  40.    Begin CommandButton Command2 
  41.       Caption         =   "Temp File"
  42.       Height          =   495
  43.       Left            =   240
  44.       TabIndex        =   1
  45.       Top             =   1200
  46.       Width           =   1215
  47.    End
  48.    Begin TextBox Text1 
  49.       Height          =   495
  50.       Left            =   1680
  51.       TabIndex        =   2
  52.       Text            =   "Text1"
  53.       Top             =   480
  54.       Width           =   3015
  55.    End
  56.    Begin CommandButton Command1 
  57.       Caption         =   "Temp Drive"
  58.       Height          =   495
  59.       Left            =   240
  60.       TabIndex        =   0
  61.       Top             =   480
  62.       Width           =   1215
  63.    End
  64. '  GetTempFileName() Flags
  65. Const TF_FORCEDRIVE = &H80
  66. Declare Function GetTempDrive Lib "Kernel" (ByVal cDriveLetter As Integer) As Integer
  67. Declare Function GetTempFileName Lib "Kernel" (ByVal cDriveLetter As Integer, ByVal lpPrefixString As String, ByVal wUnique As Integer, ByVal lpTempFileName As String) As Integer
  68. Sub Command1_Click ()
  69.   X% = 0
  70.   TempDrive% = GetTempDrive%(X%)
  71.   Text1.Text = Chr$(TempDrive% Mod 256) + Chr$(TempDrive% \ 256)
  72. End Sub
  73. Sub Command2_Click ()
  74.   DriveLetter% = Asc("C") 'Or TF_FORCEDRIVE
  75.   PrefixString$ = "BAG"
  76.   Unique% = 0  'if 0 uses time
  77.   TempFileName$ = Space$(144)
  78.   UniqueNbr% = GetTempFileName(DriveLetter%, PrefixString$, Unique%, TempFileName$)
  79.   Text2.Text = RTrim$(TempFileName$)
  80. End Sub
  81. Sub Command3_Click ()
  82.   E$ = Environ$("TEMP")
  83.   If Right$(E$, 1) <> "\" Then E$ = E$ + "\"
  84.   TestFileName$ = "TEST0001.TMP"
  85.   Ctr% = 1
  86.   Debug.Print TestFileName$
  87. Loop1:
  88.   If Len(Dir$(E$ + TestFileName$)) <> 0 Then
  89.     Text3.Text = "File: " + TestFileName$ + " exists"
  90.     Debug.Print E$ + TestFileName$
  91.     Ctr% = Ctr% + 1
  92.     Mid$(TestFileName$, 5, 4) = Format$(Ctr%, "0000")
  93.     GoTo Loop1
  94.   Else
  95.     Debug.Print E$ + TestFileName$
  96.     Text3.Text = "File: " + TestFileName$ + " doesn't exist"
  97.     Open E$ + TestFileName$ For Output As #1
  98.     Close 1
  99.   End If
  100. End Sub
  101. Sub Form_Click ()
  102.   End
  103. End Sub
  104.