Solved

INI File Help

Posted on 2007-04-09
12
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 70

Expert Comment

by:Éric Moreau
ID: 18877464
0
 
LVL 86

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 70

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
 
LVL 70

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 86

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 70

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 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