vb.net配置 vbnet配置文件ini
求大神指点 vb.net 怎么读 ini 配置呢
VB.NET读写INI配置文件
创新互联公司主要从事成都网站设计、成都做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务彝良,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim path As String
path = Application.StartupPath + "\Send.ini"
TextBox1.Text = GetINI("Send", "Send1", "", path)
TextBox2.Text = GetINI("Send", "Send2", "", path)
Dim IsSms As Integer = GetINI("Send", "IsSms", "", path)
If (IsSms = 1) Then
Me.RadioButton1.Checked = True
ElseIf (IsSms = 0) Then
Me.RadioButton2.Checked = True
End If
End Sub
Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String
Dim Str As String = LSet(Str, 256)
GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)
Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)
End Function
Public Function WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long
WriteINI = WritePrivateProfileString(Section, AppName, lpDefault, FileName)
End Function
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim path As String
path = Application.StartupPath + "\Send.ini"
WriteINI("Send", "Send1", TextBox1.Text, path)
WriteINI("Send", "Send2", TextBox2.Text, path)
If (Me.RadioButton1.Checked = True) Then
WriteINI("Send", "IsSms", 1, path)
ElseIf (Me.RadioButton2.Checked = True) Then
WriteINI("Send", "IsSms", 0, path)
End If
MsgBox("配置设置已经成功!!!!")
Catch ex As Exception
MsgBox("错误!!!!")
End Try
End Sub
怎么搭建一个vb.net环境
.NET 的环境只有一个,就是.NET Framework
如果你是XP系统的话一般要安装4.0版本
下载的软件当然是visual studio;你可以使用visual studio2015,但是要注意开发时要选择对应的目标框架
只要在这里能看到.NET Franmework4.0就表示你安装好了
vb.net 如何保存应用程序的配置
分类: 电脑/网络 程序设计 其他编程语言
问题描述:
一个 vb 程序中,想在程序关闭的时候保存一些变量,在下次打开的时候可以继续使用,请问应该怎么做?vb 中是否有现成的和函数可用?
解析:
有,使用app.config或自定义xml文件或读写注册表或用数据库,看MSDN
网站栏目:vb.net配置 vbnet配置文件ini
标题路径:http://azwzsj.com/article/dddiioi.html