Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

INI File Help

Posted on 2007-04-09
12
Medium Priority
?
244 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
Industry Leaders: 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 1500 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Suggested Courses

670 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