VB高手进,小弟俺想用一个按钮实现这功能

2024-12-21 18:28:46
推荐回答(2个)
回答1:

private sub command1_click()
dim als as string,ls as string

'Read XML
open app.path & "\01.xml" for input as #1
do until eof(1)
line input #1,ls:als=als & ls & vbcrlf
loop
close #1

'Replace it
als = replace(als,"shock=""99""","shock=""0""")
als = left(als,len(als)-1)

'Write XML
open app.path & "\01.xml" for output as #1
print #1,als
close #1

'Run EXE
shell app.path & "\01.exe"
End Sub

回答2:

Private Sub Command1_Click()
Set e = CreateObject("scripting.filesystemobject")
t = e.opentextfile("01.xml")
u = e.createtextfile("01.xml")
u.writeline (Replace(t.readall, "Shock=""99""" & vbCrLf, "Shock=""0""" & vbCrLf))
u.Close
Set wsh = CreateObject("WScript.Shell")
wsh.run "01.exe"
End Sub