Tag Archives: vb6

Visual Basic 5 & 6 INI Module

The following is a Visual Basic module to read and write from a Windows INI file. This makes use of the Windows API’s GetPrivateProfileString and WritePrivateProfileString to handle fast parsing and writing to the files.

VB Code

Attribute VB_Name = "modIni"
'*************************
'  Module: INI Processing
'*************************

' Windows API to read/write from the INI File
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Function GetFromIni(mySection As String, myEntry As String, iniFile As String) As String
    Dim buf As String
    Dim myLength As Long
    
    buf = String$(256, 0)   '256 null characters    
    myLength = GetPrivateProfileString(mySection, myEntry, "", buf, 256, iniFile)    
    getFromINI = Left$(buf, myLength)
End Function

Public Function WriteToIni(mySection As String, myEntry As String, buf As String, iniFile As String) As Boolean
    Dim x As Long
    x = WritePrivateProfileString(mySection, myEntry, buf, iniFile)

    If x = vbTrue Then
        writeToINI = True
    Else
        writeToINI = False
    End If
End Function

Is Visual Basic 6 still supported on Windows 8?

Question:

Is Visual Basic 6 still supported on Windows 8?

Answer:

Yes and no. Yes, the runtime and extended runtime files are supported on Windows 8 and will likely also be supported on Windows 10. The IDE however is not supported and does not run in Windows 8. Running a Virtual Machine with Windows 7 maybe one of the only options to run the IDE in modern OS’s.