Solved

INI File Help

Posted on 2007-04-09
12
226 Views
Last Modified: 2011-09-20
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()
0
Comment
Question by:triplebd69
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 27

Expert Comment

by:VBRocks
ID: 18877320
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()

0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 18877464
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18877570
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.
0
 

Author Comment

by:triplebd69
ID: 18877699
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?
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 18877750
>>clmINIFile and clmLogger saying type not defined?

those looks like other classes of your VB6 project.
0
 

Author Comment

by:triplebd69
ID: 18877760
Maybe, although I thought they were column names defined in the VB6 code.  I am not sure.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 69

Expert Comment

by:Éric Moreau
ID: 18877896
they really seemed to be class modules.
0
 

Author Comment

by:triplebd69
ID: 18877932
As I said I am new to VB can you tell me how to find out?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18878035
In the Project Panel there should be an entry in the TreeView called "Class Modules"...are they listed in there?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 18878075
place your cursor on the clmINIFile and press SHIFT-F2. That should get you to the class code
0
 

Author Comment

by:triplebd69
ID: 18883929
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.
0
 

Author Comment

by:triplebd69
ID: 18884732
emoreau thanks for your help you really got me looking in the right direction.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now