VB中怎样在启动窗体时自动加载图片

也就是在窗体启动时会把目录下的图片加载到窗体中。尽量说详细点……还有读、写INI文件的方法。先谢谢了……... 也就是在窗体启动时会把目录下的图片加载到窗体中。尽量说详细点……还有读、写INI文件的方法。先谢谢了…… 展开
 我来答
zenper
推荐于2017-10-07 · TA获得超过153个赞
知道小有建树答主
回答量:101
采纳率:0%
帮助的人:59.7万
展开全部
窗体启动时载入图片:

Private Sub Form_Load()
Me.Picture = LoadPicture( "路径+文件名")
End Sub

如果程序和图像文件在同一目录内可以改成:
Me.Picture = LoadPicture( App.Path & "\文件名")

读写INI文件的方法:

在工程中,新建一个模块,将如下代码粘贴进去!
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Public Sub WriteToIni(ByVal FileName As String, ByVal Section As String, ByVal Key As String, ByVal Value As String)
Dim buff As String * 128
buff = Value + Chr(0)
WritePrivateProfileString Section, Key, buff, FileName
End Sub

Public Function ReadFromIni(ByVal FileName As String, ByVal Section As String, ByVal Key As String) As String
Dim i As Long
Dim buff As String * 128
GetPrivateProfileString Section, Key, "", buff, 128, FileName
i = InStr(buff, Chr(0))
ReadFromIni = Trim(Left(buff, i - 1))
End Function

在Form窗体代码某事件【比如:Form_Load()事件】 过程中,
’读取INI文件的例子皮拍
Dim p As String
p=ReadFromIni("路燃告羡径+INI文件名", "名称1", "名称2")
比如:p=ReadFromIni("d:\MusicPlayer.ini", "设置", "文件夹路径")

’写入INI文件的例子
WriteToIni "路径+INI文件名"友掘, "名称1", "名称2","字符串或者一个变量"
比如:
WriteToIni "d:\MusicPlayer.ini", "设置", "文件夹路径", "e:\mymusic"
或者:
dim f as string
f="e:\mymusic"
WriteToIni "d:\MusicPlayer.ini", "设置", "文件夹路径", f
不远不近de距离
2010-10-10
知道答主
回答量:16
采纳率:0%
帮助的人:0
展开全部
Private Sub Form_Load()
FORM1(这里写你察慎要加备山载的图片的那个窗体的名仿没中称).Picture = LoadPicture( "路径+文件名")
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式