473,383 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Reading an INI file

I'm reading an INI file and all is working fine. However, when I turn Option
Explicit "On" (it's currently "Off"), I get errors. Here is my pertinent
code:

Dim lpAppName As String

Dim lpKeyName As String

Dim lpDefault As String

Dim lpReturnedString As New System.Text.StringBuilder(256)

Dim lpNsize As Integer

Dim lpFileName As String

Private Declare Auto Function GetPrivateProfileString Lib "kernel32" _

(ByVal lpAppName As String, _

ByVal lpKeyName As String, _

ByVal lpDefault As String, _

ByVal lpReturnedString As System.Text.StringBuilder, _

ByVal lpNsize As Integer, _

ByVal lpFileName As String) As Integer

lpAppName = strParentName

lpDefault = ""

lpReturnedString = New System.Text.StringBuilder(256)

lpNsize = 256

lpFileName = Application.StartupPath & "\controls.ini"

lpKeyName = "P1_JOYSTICK_UP"

GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpReturnedString,
lpNsize, lpFileName)

If lpReturnedString.ToString() <> "" Then

lbl1.Visible = True

lbl1.Text = lpReturnedString.ToString()

End If

It doesn't like the lpReturnedString parameter in the
GetPrivateProfileString function(not sure if the verbage is correct there).
What do I need to do to turn Option Strict "On" or should I not worry about
it?

Thanks,

John
Nov 21 '05 #1
18 1221
John,

I have been strugling with your problem about making faster the painting of
the labels. I told you I am not a painter (I do not like it working with all
those different pointers in differnt places on different layers) The
chalenge of course is not getting it working however making it faste.

Doing that I more and more got the idea why is John using labels instead of
picture boxes. Did you try that already. Without any expirience in that I
have he thouht that that maybe would make things much more easier to set as
picture in the box and than that probably would make moving easier.

So before I (or you) try that, did you had a reason for that?

Your problem in this message is probably that the declare is in the middle
of a procedure, in a procedure you can only declare with Dim, so just put it
outside the procedure, looks as well much nicer.

Another thing when most of use show code, we do not directly past from the
designer in the message. We past it first in a textbox. That makes that you
can see the code in one screen and gives you as sender more change on an
answer because the problem is easier and faster to see.

I hope this helps?

Cor
"jcrouse" <me>
I'm reading an INI file and all is working fine. However, when I turn Option Explicit "On" (it's currently "Off"), I get errors. Here is my pertinent
code:

Dim lpAppName As String

Dim lpKeyName As String

Dim lpDefault As String

Dim lpReturnedString As New System.Text.StringBuilder(256)

Dim lpNsize As Integer

Dim lpFileName As String

Private Declare Auto Function GetPrivateProfileString Lib "kernel32" _

(ByVal lpAppName As String, _

ByVal lpKeyName As String, _

ByVal lpDefault As String, _

ByVal lpReturnedString As System.Text.StringBuilder, _

ByVal lpNsize As Integer, _

ByVal lpFileName As String) As Integer

lpAppName = strParentName

lpDefault = ""

lpReturnedString = New System.Text.StringBuilder(256)

lpNsize = 256

lpFileName = Application.StartupPath & "\controls.ini"

lpKeyName = "P1_JOYSTICK_UP"

GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpReturnedString,
lpNsize, lpFileName)

If lpReturnedString.ToString() <> "" Then

lbl1.Visible = True

lbl1.Text = lpReturnedString.ToString()

End If

It doesn't like the lpReturnedString parameter in the
GetPrivateProfileString function(not sure if the verbage is correct there). What do I need to do to turn Option Strict "On" or should I not worry about it?

Thanks,

John

Nov 21 '05 #2
I always paste my code in MS Word first. I have no idea why it posts the way
it does. I've even checked the paragraph formatting/Line spacing and
everything looks good. Next time I'll try and paste into Notepad and see
what happens. As far as Pic Box. No I have not tried that. I'll look into
it. I am also going to try a test in VB6 to see if there is any difference.

Later,
John

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
John,

I have been strugling with your problem about making faster the painting of the labels. I told you I am not a painter (I do not like it working with all those different pointers in differnt places on different layers) The
chalenge of course is not getting it working however making it faste.

Doing that I more and more got the idea why is John using labels instead of picture boxes. Did you try that already. Without any expirience in that I
have he thouht that that maybe would make things much more easier to set as picture in the box and than that probably would make moving easier.

So before I (or you) try that, did you had a reason for that?

Your problem in this message is probably that the declare is in the middle
of a procedure, in a procedure you can only declare with Dim, so just put it outside the procedure, looks as well much nicer.

Another thing when most of use show code, we do not directly past from the
designer in the message. We past it first in a textbox. That makes that you can see the code in one screen and gives you as sender more change on an
answer because the problem is easier and faster to see.

I hope this helps?

Cor
"jcrouse" <me>
I'm reading an INI file and all is working fine. However, when I turn

Option
Explicit "On" (it's currently "Off"), I get errors. Here is my pertinent
code:

Dim lpAppName As String

Dim lpKeyName As String

Dim lpDefault As String

Dim lpReturnedString As New System.Text.StringBuilder(256)

Dim lpNsize As Integer

Dim lpFileName As String

Private Declare Auto Function GetPrivateProfileString Lib "kernel32" _

(ByVal lpAppName As String, _

ByVal lpKeyName As String, _

ByVal lpDefault As String, _

ByVal lpReturnedString As System.Text.StringBuilder, _

ByVal lpNsize As Integer, _

ByVal lpFileName As String) As Integer

lpAppName = strParentName

lpDefault = ""

lpReturnedString = New System.Text.StringBuilder(256)

lpNsize = 256

lpFileName = Application.StartupPath & "\controls.ini"

lpKeyName = "P1_JOYSTICK_UP"

GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpReturnedString, lpNsize, lpFileName)

If lpReturnedString.ToString() <> "" Then

lbl1.Visible = True

lbl1.Text = lpReturnedString.ToString()

End If

It doesn't like the lpReturnedString parameter in the
GetPrivateProfileString function(not sure if the verbage is correct

there).
What do I need to do to turn Option Strict "On" or should I not worry

about
it?

Thanks,

John


Nov 21 '05 #3
* "jcrouse" <me> scripsit:
I'm reading an INI file and all is working fine. However, when I turn Option
Explicit "On" (it's currently "Off"), I get errors. Here is my pertinent
code:


<URL:http://www.mentalis.org/soft/class.qpx?id=6>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
Herfried,

What has this answer to do with a "private" declaration inside a function?

Cor

<URL:http://www.mentalis.org/soft/class.qpx?id=6>

Nov 21 '05 #5
* "Cor Ligthert" <no**********@planet.nl> scripsit:
What has this answer to do with a "private" declaration inside a function?
<URL:http://www.mentalis.org/soft/class.qpx?id=6>


It's a replacement that will make dealing with INI files easier.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6
> > What has this answer to do with a "private" declaration inside a
function?
<URL:http://www.mentalis.org/soft/class.qpx?id=6>


It's a replacement that will make dealing with INI files easier.


Than tell that in the message because that was not the question.

This is confusing even for me, who knows that you drops this with every
qeustion about a INI, I had the plan for looking for a link on that on
Google this morning using your name and INI, but saw it was not the
question.

Cor
Nov 21 '05 #7
* "Cor Ligthert" <no**********@planet.nl> scripsit:
Your problem in this message is probably that the declare is in the middle
of a procedure, in a procedure you can only declare with Dim, so just put it
outside the procedure, looks as well much nicer.


This cannot be the case, because the code works with 'Option Strict'
turned off.
I'm reading an INI file and all is working fine. However, when I turn

Option
Explicit "On" (it's currently "Off"), I get errors. Here is my pertinent


--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #8
Herfried,

Where is John talking about Option Strict?

Although I look mostly (when it is not 5 pages) mostly also to the code.

You think that can works fine with Option Strict Off and option Explicit On?

Cor

* "Cor Ligthert" <no**********@planet.nl> scripsit:
Your problem in this message is probably that the declare is in the middle
of a procedure, in a procedure you can only declare with Dim, so just put it outside the procedure, looks as well much nicer.
This cannot be the case, because the code works with 'Option Strict'
turned off.
I'm reading an INI file and all is working fine. However, when I turn

Option
Explicit "On" (it's currently "Off"), I get errors. Here is my

pertinent
--

Nov 21 '05 #9
* "Cor Ligthert" <no**********@planet.nl> scripsit:
Where is John talking about Option Strict?
Ooops. Typo. I wanted to type 'Option Explicit'.
Although I look mostly (when it is not 5 pages) mostly also to the code.

You think that can works fine with Option Strict Off and option Explicit On?


No. If you put the declare into a method's body, the code should not
compile at all, independent from the settings for 'Option Strict' and
'Option Explicit'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #10
Herfried,
No. If you put the declare into a method's body, the code should not
compile at all, independent from the settings for 'Option Strict' and
'Option Explicit'.


Did I say that,

When John (the OP) says so it does.

:-)))))

I showed you now a typical Herfried answer,

:-)

However you are right, but it was in his code, so removing would be the this
first thing to do.
Maybe he changed something and did not notice it or something and did it
gave an error assuming it was the option explictit which he changed in the
same time.

Cor
Nov 21 '05 #11
* "Cor Ligthert" <no**********@planet.nl> scripsit:
No. If you put the declare into a method's body, the code should not
compile at all, independent from the settings for 'Option Strict' and
'Option Explicit'.


Did I say that,

When John (the OP) says so it does.


I assume that John has composed the code the way it showed up in the
post especially for the purpose of this post. It's not an 1:1 copy of
his code, I think.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #12
Herfried,
No. If you put the declare into a method's body, the code should not
compile at all, independent from the settings for 'Option Strict' and
'Option Explicit'.


Did I say that,

When John (the OP) says so it does.


I assume that John has composed the code the way it showed up in the
post especially for the purpose of this post. It's not an 1:1 copy of
his code, I think.


Very bad quoting, it puts my sentence in a completly wrong context

I strongly advise you to read these pages

Improve your quoting style:
http://learn.to/quote

http://www.plig.net/nnq/nquote.html

Cor
Nov 21 '05 #13
* "Cor Ligthert" <no**********@planet.nl> scripsit:
No. If you put the declare into a method's body, the code should not
compile at all, independent from the settings for 'Option Strict' and
'Option Explicit'.

Did I say that,

When John (the OP) says so it does.


I assume that John has composed the code the way it showed up in the
post especially for the purpose of this post. It's not an 1:1 copy of
his code, I think.


Very bad quoting, it puts my sentence in a completly wrong context


Bla bla...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #14
Herfried,

In future I will deal with you in the context of this message from you.

Very bad quoting, it puts my sentence in a completly wrong context


Bla bla...


Nov 21 '05 #15
* "Cor Ligthert" <no**********@planet.nl> scripsit:
In future I will deal with you in the context of this message from you.


There are things where commenting doesn't make sense. When I don't
quote parts of the message this is /always/ (remember /always/)
intentional.

SCNR

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #16
> > In future I will deal with you in the context of this message from you.

There are things where commenting doesn't make sense. When I don't
quote parts of the message this is /always/ (remember /always/)
intentional.

Bla bla...
Nov 21 '05 #17
* "Cor Ligthert" <no**********@planet.nl> scripsit:
In future I will deal with you in the context of this message from you.


There are things where commenting doesn't make sense. When I don't
quote parts of the message this is /always/ (remember /always/)
intentional.


Bla bla...


"If you can't imitate him, don't copy him."
(Yogi Berra)

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #18
> >>> In future I will deal with you in the context of this message from
you.

There are things where commenting doesn't make sense. When I don't
quote parts of the message this is /always/ (remember /always/)
intentional.


Bla bla...


"If you can't imitate him, don't copy him."
(Yogi Berra)


Do you understand that sentence?

Nov 21 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
1
by: Need Helps | last post by:
Hello. I'm writing an application that writes to a file a month, day, year, number of comments, then some strings for the comments. So the format for each record would look like:...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.