Link to home
Start Free TrialLog in
Avatar of triplebd69
triplebd69

asked on

INI File Help

I am converting a VB6 module to VB.NET.  I am new to VB and need some help.  The origial code and new is below.  I don't see what data type in .NET to declare for the column name like was done in VB6.  As I said I am new to VB so all the help I can get would be great.

VB6 Code
Option Explicit

Const HourINIFile = "\Program Files\Rite Aid\Vru\Data\HolidayHours.ini"
Const CfgINIFile = "\Program Files\Rite Aid\Vru\Data\RAPSCfg.ini"
Const MODULE_NAME = "mHolidayHours"
Dim usrctlINIFileReader As New clmINIFile
Dim usrctlLogger As New clmLogger
Dim gboolHolThisWeek As Boolean

Sub Main()
    Const INIMONITORFILE = "\Program Files\Rite Aid\Vru\Data\Monitor.ini"
    Const PROCEDURE_NAME = "Form_Load"
    Dim strHldData As String, strErrDesc As String, lngErrNumber As Long
   
    On Error GoTo LOCAL_ERROR_HANDLER
    Trace (" ")
    Trace ("Application Started")
   
    gboolHolThisWeek = False
   
    strHldData = Format(Now, "mm/dd/yy hh:mm:ss AMPM")
    usrctlINIFileReader.raWriteINI "HOLIDAYHOURS", "TimeStarted", strHldData, INIMONITORFILE
    usrctlINIFileReader.raWriteINI "HOLIDAYHOURS", "CurrentStatus", "Running", INIMONITORFILE
    If Dir(CfgINIFile) = "" Then
        Trace ("Missing RapsCfg.ini. Application will end now")
        GoTo EXIT_PROCEDURE
    ElseIf Dir(HourINIFile) = "" Then
        Trace ("Missing HolidayHours.ini. Application will end now")
        GoTo EXIT_PROCEDURE
    End If
    Call Check4UpComingHoliday

VB.NET
Option Explicit On
Module mHolidayHours

    Const HourINIFile = "\Program Files\Rite Aid\Vru\Data\HolidayHours.ini"
    Const CfgINIFile = "\Program Files\Rite Aid\Vru\Data\RAPSCfg.ini"
    Const MODULE_NAME = "HolidayHours"

    'Dim usrctlINIFileReader As New clmINIFile

    'Dim usrctlLogger As New clmLogger
    Dim usrctlLogger As New DataColumn
    Dim gboolHolThisWeek As New Boolean

    Sub Main()
        Const INIMONITORFILE = "\Program Files\Rite Aid\Vru\Data\Monitor.ini"
        Const PROCEDURE_NAME = "Form_Load"
        Dim strHldData, strErrDesc As String
        Dim lngErrnumber As Integer

        Try
            TRACE(" ")
            TRACE("Application Started")

            gboolHolThisWeek = False

            strHldData = Format(Now, "mm/dd/yy hh:mm:ss AMPM")
            'usrctlINIFileReader.raWriteINI("HOLIDAYHOURS", "TimeStarted", strHldData, INIMONITORFILE)
            'usrctlINIFileReader.raWriteINI("HOLIDAYHOURS", "CurrentStatus", "Running", INIMONITORFILE)

            If Dir(CfgINIFile) = "" Then
                TRACE("Missing RapsCfg.ini. Application will end now")
                End
            ElseIf Dir(HourINIFile) = "" Then
                TRACE("Missing HolidayHours.ini. Application will end now")
                End
            End If

            Call Check4UpComingHoliday()
Avatar of VBRocks
VBRocks
Flag of United States of America image

Just a suggestion - in .NET, you can add a Settings file to your program.  I'm not entirely certain, because I really haven't used .ini files much, but a Settings file can store values that are used by the application (application and user specific).  It is very easy to set and retrieve these values.

1.  Just add a Settings file to your project.
2.  Add a string (or whatever type) row to the resource file, such as "HolidayHoursTimeStarted"
3.  Set the type (string)
4.  Set the scope (user or application)
5.  Set the default value to whatever you would like it to be.

Then, in your code you can retrieve the value as follows:
Dim str as String
str = My.Settings.HolidayHoursTimeStarted

You can also save a value in code as follows
My.Settings.HolidayHoursTimeStarted = strHldData
My.Settings.Save()

If you want to keep your old code you should be able to just change all "Long" data type occurrences to "Integer".  Don't forget to do this in your API declarations as well!

On a side note, the My.XXX functions only exist in VB.Net 2005.
Avatar of triplebd69
triplebd69

ASKER

Thanks to all for your help.  Idle_Mind, if I just convert all of the logs to ints I get an error about the
Dim usrctlINIFileReader As New clmINIFile
Dim usrctlLogger As New clmLogger
clmINIFile and clmLogger saying type not defined?
Any help with error?  What is causing and what type it should be?
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada 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
Maybe, although I thought they were column names defined in the VB6 code.  I am not sure.
they really seemed to be class modules.
As I said I am new to VB can you tell me how to find out?
In the Project Panel there should be an entry in the TreeView called "Class Modules"...are they listed in there?
place your cursor on the clmINIFile and press SHIFT-F2. That should get you to the class code
Thanks the shift F2 didn't do anything.  I was able to go to an old system and found 2 dll files named INIControl and Logger, but I cant regester them get an error about the dd being l;oaded but entry point? and the dll is not regestered.  In the VS 2005 IDE under referances I can see the dll's but when I build it it says that clmINIFile and clmLogger re not defined.
emoreau thanks for your help you really got me looking in the right direction.