Create Temporary Files

Create Temporary Files

I’m developing a database program that deals with many auxiliary files at same time. Everyone codingdatabase programs must create some temporary files to produce an output from SQL or a temporarydatabase to manipulate those records efficiently. I decided to create a FileAux function that returns onetemporary file name. If I need to create more than one file into the same process, I simply store those namesinto variables I dimensioned before:

 Function FileAux(Ext As String) _        As String        Dim i As Long, X As String        If InStr(Ext, ".") = 0 Then                Ext = "." + Ext        End If        'Look for the previous files in the         'HardDisk        i = 0        Do                 X = "Aux" + Format$(i, "0000") _                        + Ext                If FileExists(X) Then                        i = i + 1                Else                        Exit Do                End If        Loop        FileAux = XEnd Function

This function uses the “FileExists” function:

 Function FileExist(filename As String) _        As Boolean        FileExist = Dir$(filename) <> ""End Function

Here’s an example of its usage:

 Sub Test()        Dim File1 As String, File2 As _                String, File3 As String        Dim DB1 As database, DB2 As DataBase        Dim FileNum As Integer        File1 = FileAux("MDB")        Set DB1 = CreateDataBase(File1)        File2 = FileAux("MDB")        Set DB2 = CreateDataBase(File2)        File3 = FileAux("TXT")        FileNum = FreeFile        Open File3 For OutPut As FileNum        'Your code        ' ...        Close FileNumEnd Sub

File1, File2, and File3 should be “Aux0001.MDB,” “Aux0002.MDB,” and “Aux0001.TXT,” respectively.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of