Advertisement
ElliottE4

Untitled

Feb 18th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.91 KB | None | 0 0
  1. Imports System.IO 'imports the system.io library to be used
  2.  
  3. Module GetFile 'creates a global module called GetFile
  4.  
  5.     Public staffFile As String 'creates variable to hold the staff textfile location
  6.     Public Security As Integer 'creates variable to hold the current user's security level
  7.  
  8.     Public Sub getfilelocation() 'creates a subroutine to set the staffFile variable to the location of the textfile
  9.  
  10.         staffFile = Application.StartupPath & "\staff.txt" 'makes the staffFile variable store the file path
  11.  
  12.         If Dir$(staffFile) = "" Then 'if the staff textfile doesn't exist:
  13.  
  14.             Dim sw1 As New StreamWriter(staffFile, True) 'the streamwriter is opened to create the file at the location
  15.             MsgBox("Staff File created") 'confirmation message shown
  16.             sw1.Close() 'closes the streamwriter to prevent data being deleted
  17.  
  18.         End If
  19.  
  20.     End Sub
  21.  
  22. End Module
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement