先按照格式读出TXT中的数据 然后写,下面是我用的 If Text19.Text <> "" And Text20.Text <> "" And Text2.Text <> "" And Text21.Text <> "" _ And Text22.Text <> "" And Text23.Text <> "" And Text13.Text <> "" And Text5.Text <> "" _ And Text6.Text <> "" And Text7.Text <> "" And Text9.Text <> "" _ And Text10.Text <> "" And Text1.Text <> "" And Text11.Text <> "" Then Dim AppPath As String * 256 Dim AppPathName As String Dim lResult As Long lResult = GetCurrentDirectory(256, AppPath) If lResult = 0 Then MsgBox ("无法获取当前执行目录") Exit Sub End If AppPathName = App.Path & "\syscon.ini" ' AppPathName = "D:\资料\中心\VB_DEMO_源代码\SysConf.ini" Dim strSection As String, strKey As String, strValue As String strSection = "Param_con" strKey = "mas_vol_com" strValue = Trim(Text19) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If
strKey = "mas_cur_com" strValue = Trim(Text20) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If
strKey = "cap_vol_com" strValue = Trim(Text2) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If
strKey = "cap_cur_com" strValue = Trim(Text21) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If
strKey = "his_Interval" strValue = Trim(Text23) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If
strKey = "cur1_angle_cor" strValue = Trim(Text22) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If strKey = "cur2_angle_cor" strValue = Trim(Text13) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If strKey = "cap_beyond_vol_rate" strValue = Trim(Text5) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If strKey = "cap_beyond_cur_rate" strValue = Trim(Text6) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If strKey = "cap_below_cur_rate" strValue = Trim(Text7) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If strKey = "mas_beyond_vol_rate" strValue = Trim(Text9) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If strKey = "mas_below_vol_rate" strValue = Trim(Text10) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If ' strKey = "reactor_beyond_degree" ' strValue = Trim(Text8) ' If WritePrivateProfileString(strSection, strKey, _ ' strValue, AppPathName) = 0 Then ' MsgBox ("写INI文件错误") ' Exit Sub ' End If
strKey = "same_wave_alert" strValue = Trim(Text1) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If
strKey = "same_wave_cut" strValue = Trim(Text11) If WritePrivateProfileString(strSection, strKey, _ strValue, AppPathName) = 0 Then MsgBox ("写INI文件错误") Exit Sub End If MsgBox "数据保存完毕", vbOKOnly, "提示!" Exit Sub Else MsgBox "数据不完整,无法保存", vbOKOnly, "警告!" Exit Sub End If‘’‘’‘’‘’‘’‘’‘’‘’‘’‘ 我的INI文件是这样配置的 [control_con] first=400 second=700 third=1050 forth=1700 fifth=2500 sixth=3400 seventh=4500 eighth=5300 ninth=6000 tenth=6000 cos_eleventh=90 cos_twelveth=98 mode=2 delay_thirteenth=20 min_current=0
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
然后把xmlhttp.ResponseText保存到xxxx.ini
Inet1.Execute "http://www.abc.com", "GET xxxx.txt C:\xxxx.ini"
然后写,下面是我用的
If Text19.Text <> "" And Text20.Text <> "" And Text2.Text <> "" And Text21.Text <> "" _
And Text22.Text <> "" And Text23.Text <> "" And Text13.Text <> "" And Text5.Text <> "" _
And Text6.Text <> "" And Text7.Text <> "" And Text9.Text <> "" _
And Text10.Text <> "" And Text1.Text <> "" And Text11.Text <> "" Then
Dim AppPath As String * 256
Dim AppPathName As String
Dim lResult As Long
lResult = GetCurrentDirectory(256, AppPath)
If lResult = 0 Then
MsgBox ("无法获取当前执行目录")
Exit Sub
End If
AppPathName = App.Path & "\syscon.ini"
' AppPathName = "D:\资料\中心\VB_DEMO_源代码\SysConf.ini"
Dim strSection As String, strKey As String, strValue As String
strSection = "Param_con"
strKey = "mas_vol_com"
strValue = Trim(Text19)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "mas_cur_com"
strValue = Trim(Text20)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "cap_vol_com"
strValue = Trim(Text2)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "cap_cur_com"
strValue = Trim(Text21)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "his_Interval"
strValue = Trim(Text23)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "cur1_angle_cor"
strValue = Trim(Text22)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "cur2_angle_cor"
strValue = Trim(Text13)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "cap_beyond_vol_rate"
strValue = Trim(Text5)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "cap_beyond_cur_rate"
strValue = Trim(Text6)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "cap_below_cur_rate"
strValue = Trim(Text7)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "mas_beyond_vol_rate"
strValue = Trim(Text9)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "mas_below_vol_rate"
strValue = Trim(Text10)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
' strKey = "reactor_beyond_degree"
' strValue = Trim(Text8)
' If WritePrivateProfileString(strSection, strKey, _
' strValue, AppPathName) = 0 Then
' MsgBox ("写INI文件错误")
' Exit Sub
' End If
strKey = "same_wave_alert"
strValue = Trim(Text1)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
strKey = "same_wave_cut"
strValue = Trim(Text11)
If WritePrivateProfileString(strSection, strKey, _
strValue, AppPathName) = 0 Then
MsgBox ("写INI文件错误")
Exit Sub
End If
MsgBox "数据保存完毕", vbOKOnly, "提示!"
Exit Sub
Else
MsgBox "数据不完整,无法保存", vbOKOnly, "警告!"
Exit Sub
End If‘’‘’‘’‘’‘’‘’‘’‘’‘’‘
我的INI文件是这样配置的
[control_con]
first=400
second=700
third=1050
forth=1700
fifth=2500
sixth=3400
seventh=4500
eighth=5300
ninth=6000
tenth=6000
cos_eleventh=90
cos_twelveth=98
mode=2
delay_thirteenth=20
min_current=0