读取INI文件 [英] Reading an INI file
问题描述
我正在读一个INI文件,一切正常。但是,当我转动选项
明确的开时(它当前是关闭),我收到错误。这是我的相关
代码:
Dim lpAppName As String
Dim lpKeyName As String
Dim lpDefault As String
Dim lpReturnedString As New System.Text.StringBuilder(256)
Dim lpNsize作为整数
Dim lpFileName As String
私有声明自动函数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)
如果lpReturnedString.ToString()<> ""然后
lbl1.Visible = True
lbl1.Text = lpReturnedString.ToString()
结束如果
它不喜欢
GetPrivateProfileString函数中的lpReturnedString参数(不确定那里的verbage是否正确)。
我需要做什么来改变Option Strict" On"或者我不应该担心
吗?
谢谢,
John
John,
我一直在努力解决你加快绘画的问题。
标签。我告诉过你我不是画家(我不喜欢它与所有
在不同层上的不同位置使用不同的指针)
chalenge当然没有得到然而它正在起作用。
这样做我越来越明白为什么John使用标签代替
图片框。你有没有尝试过在没有任何实际情况的情况下,我认为这可能会让事情变得更加容易,因为盒子中的图片可能更容易让人感觉更轻松。
所以在我(或你)尝试之前,你有没有理由这样做?
你在这条消息中的问题可能是声明是在一个程序的中间
,在一个程序中你只能用Dim声明,所以只需把它放在程序之外的
,看起来也好得多。
当大多数使用显示代码时,我们不会直接从消息中的
设计器过去。我们先在文本框中浏览它。这使得你可以在一个屏幕上看到代码,并在
答案中为发件人提供更多更改,因为这个问题更容易,更快查看。
我希望这有帮助吗?
Cor
" jcrouse" < me>我正在读一个INI文件,一切正常。但是,当我转向
Option ExplicitOn时(它当前是关闭),我收到错误。这是我的相关代码:
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
私有声明自动函数GetPrivateProfileString Lib" kernel32" _
(ByVal lpAppName As String,_
ByVal lpKeyName As String,_
ByVal lpDefault As String,_
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)
如果lpReturnedString.ToString()<> ""然后
lbl1.Visible = True
lbl1.Text = lpReturnedString.ToString()
结束如果
它不喜欢
GetPrivateProfileString函数中的lpReturnedString参数(不确定verbage是否正确
)。我需要做什么才能打开Option StrictOn或者我不应该担心
吗?
谢谢,
>
我总是先将代码粘贴到MS Word中。我不知道为什么它会发布它的方式
。我甚至检查了段落格式/行间距和
一切看起来都不错。下次我会尝试粘贴到记事本中,看看
会发生什么。至于Pic Box。不,我没有尝试过。我会调查
吧。我也打算在VB6中尝试测试是否有任何区别。
后来,
John
Cor Ligthert <无********** @ planet.nl>在消息中写道
news:e3 ************** @ TK2MSFTNGP09.phx.gbl ...John,>
我一直在努力解决你的问题,即加快标签的绘画价格
。我告诉过你我不是画家(我不喜欢它在
上使用不同层上不同位置的所有不同指针)当然,
chalenge并不是让它工作,而是让它紧固。
这样做我越来越明白为什么John使用标签代替
的图片框。你有没有尝试过在没有任何实际情况的情况下,我认为他可能会更容易将
设置为框中的图片,而这可能会使移动变得更容易。
所以在我(或你)尝试之前,你有没有理由这样做?
你在这个消息中的问题可能是声明在一个程序的中间,在一个程序中程序你只能用Dim声明,所以只需把
放在程序之外,看起来也好得多。
当大多数使用显示代码的另一件事,我们不直接从过去
设计师在留言中。我们先在文本框中浏览它。这使得
你可以在一个屏幕上看到代码并让你作为发送者在
答案上有更多的变化,因为问题更容易和更快看到。
我希望这个帮助?
" jcrouse" < me>我正在读一个INI文件,一切正常。但是,当我转
选项明确的开时(它当前是关闭),我收到错误。这是我的相关代码:
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
私有声明自动函数GetPrivateProfileString Lib" kernel32" _
(ByVal lpAppName As String,_
ByVal lpKeyName As String,_
ByVal lpDefault As String,_
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)
如果lpReturnedString.ToString()<> ""然后
lbl1.Visible = True
lbl1.Text = lpReturnedString.ToString()
结束如果
它不喜欢GetPrivateProfileString函数中的lpReturnedString参数(不确定verbage是否正确
)。我需要做什么选项严格开启或者我不应该担心
关于它?
谢谢,
John
*" jcrouse" < ME> scripsit:我正在读一个INI文件,一切正常。但是,当我转动选项
明确的开时(它当前是关闭),我收到错误。这是我的相关代码:
< URL:http://www.mentalis.org/soft/class.qpx?id = 6>
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/ >
VB< URL:http://dotnet.mvps.org/dotnet/faqs/>
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
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
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
OptionExplicit "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
aboutit?
Thanks,
John
* "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/>
这篇关于读取INI文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!