Solved

INI File Help

Posted on 2007-04-09
12
229 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

910 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

23 Experts available now in Live!

Get 1:1 Help Now