Link to home
Start Free TrialLog in
Avatar of daneburr
daneburrFlag for United States of America

asked on

Get Command Box Caption from .ini

This should be simple but its been awhile 4 me...
I have 4 Command Boxes: Command1, Command2, Command3, Command4.
In the form load I need all to command box captions to change according to an .ini file (path/name) c:\vbTest.ini
In the .ini It has this:
1- One
2- Two
3- Three
4- Four
____
I need the caption on the actual command box to have only the letters, Like:
One
Two
Three
Four

using vb6pro
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

There are some API's for saving and reading files in the .ini format.
The snippet shows how to use both.
Option Explicit
Private 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
Private 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
 
Private Sub SaveMySetting()
Dim r As Long
 
r = WritePrivateProfileString("MyApp", "1", "One", "C:\vbTest.ini")
End Sub
 
Private Sub Form_Load()
Dim strBuffer As String * 20
Dim strEntry As String
Dim r As Long
Dim l As Long
l = 20
 
r = GetPrivateProfileString("MyApp", "1", "", strBuffer, l, "C:\vbTest.ini")
strEntry = Left$(strBuffer, l)
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin