以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  txt文件增加内容  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=153908)

--  作者:huhu
--  发布时间:2020/8/27 11:16:00
--  txt文件增加内容
现在生成的txt内容是
env_00230248773.dat    sn: 00230248773    mac: 9845.62fa.4a20    
env_00230248774.dat    sn: 00230248774    mac: 9845.62fa.4a30    
env_00230248775.dat    sn: 00230248775    mac: 9845.62fa.4a40    
希望能做成下面内容,相比原txt增加了key和ssid。key是随机生成的8位都是小写,ssid是有DDTV-和mac地址后6位组成,都是大写。
env_00230248773.dat    sn: 00230248773    mac: 9845.62fa.4a20    key: wueyeq5x    ssid: DTTV-FA4A20
env_00230248774.dat    sn: 00230248774    mac: 9845.62fa.4a30    key: r7fywazv      ssid: DTTV-FA4A30
env_00230248775.dat    sn: 00230248775    mac: 9845.62fa.4a40    key: d72ea9m3    ssid: DTTV-FA4A40

click代码:
Dim startSN As WinForm.TextBox = e.Form.Controls("TextBox11")
Dim xqsl As WinForm.TextBox = e.Form.Controls("TextBox22")
Dim endsn As WinForm.TextBox = e.Form.Controls("TextBox55")
Dim epromlj As WinForm.TextBox = e.Form.Controls("TextBox88")
Dim txtlj As WinForm.TextBox = e.Form.Controls("TextBox01")

Dim id11 As Integer = CInt(startSN.text)
Dim id22 As Integer = CInt(xqsl.text)
Dim id33 As Integer = id11 + id22 - 1
Endsn.text = id33

Dim inilj As WinForm.TextBox = e.Form.Controls("TextBox44")
Dim iniwj As WinForm.TextBox = e.Form.Controls("TextBox33")
Dim pfid As Integer = Inilj.text .IndexOf(":")
Dim pfwj As String = Inilj.text.Substring(0,pfid + 1)
Dim id As Integer = inilj.text.lastindexof("\\")
Dim lj As String = inilj.text.Substring(0,id) & "\\"
Dim p As new Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False \'关闭Shell的使用
p.StartInfo.RedirectStandardInput = True \'重定向标准输入
p.StartInfo.RedirectStandardOutput = True \'重定向标准输出
p.StartInfo.RedirectStandardError = True \'重定向错误输出
p.StartInfo.CreateNoWindow = False \'设置不显示窗口
p.Start()
p.StandardInput.WriteLine(pfwj)
p.StandardInput.WriteLine("cd" & " " & lj)
p.StandardInput.WriteLine(e.Form.Controls("TextBox7").text & " " & e.Form.Controls("TextBox11").Text & " " & e.Form.Controls("TextBox22").Text & " " & e.Form.Controls("TextBox33").Text, 1)
p.StandardInput.WriteLine("exit")
Dim id3 As Integer = Iniwj.text.IndexOf(".")
Dim Iniwjlj As String = Iniwj.text.SubString(0,id3)
Dim txtstr As String = Iniwjlj & "(" & e.Form.Controls("TextBox11").text & "-" & e.Form.Controls("TextBox55").text & ")" & ".txt"
txtlj.text = lj & txtstr         \'txtljtxt这个文件怎么处理才能实现这个需求呢?
epromlj.text = lj
MessageBox.show("INI文件:" & e.Form.Controls("TextBox33").Text & vbcrlf & "需求数量:" & e.Form.Controls("TextBox22").Text & vbcrlf & "生成目录:" & lj,"eprom生成完成",MessageBoxButtons.OK,MessageBoxIcon.Information )

--  作者:有点蓝
--  发布时间:2020/8/27 12:05:00
--  
比如

Dim s As String = "env_00230248773.dat    sn: 00230248773    mac: 9845.62fa.4a20"
s = s  & " key:" & Rand.NextString(8).ToLower &  " ssid: " & right(s,7).replace(".","").ToUpper
msgbox(s)

--  作者:huhu
--  发布时间:2020/8/27 13:17:00
--  
Dim txtstr As String = Iniwjlj & "(" & e.Form.Controls("TextBox11").text & "-" & e.Form.Controls("TextBox55").text & ")" & ".txt"
txtlj.text = lj & txtstr         \'txtljtxt这个文件怎么处理才能实现这个需求呢?
epromlj.text = lj
msgbox(0)
Dim strs As String = FileSys.ReadAllText(lj & txtstr)
strs = strs.Replace(vblf,"")
Dim rs() As String = strs.Split(vbcr)
For i As Integer = 0 To rs.Length - 1
    strs = strs  & "     key:" & Rand.NextString(8).ToLower &  "     ssid:DTTV- " & right(rs(i),7).replace(".","").ToUpper
Next
txtstr = strs


没实现。请帮忙看看哪里问题?

--  作者:有点蓝
--  发布时间:2020/8/27 13:41:00
--  
Dim txtstr As String = Iniwjlj & "(" & e.Form.Controls("TextBox11").text & "-" & e.Form.Controls("TextBox55").text & ")" & ".txt"
txtlj.text = lj & txtstr         \'txtljtxt这个文件怎么处理才能实现这个需求呢?
epromlj.text = lj

Dim strs As String = FileSys.ReadAllText(lj & txtstr)
msgbox(strs )
strs = strs.Replace(vblf,"")
Dim rs() As String = strs.Split(vbcr)
For i As Integer = 0 To rs.Length - 1
    strs = strs  & rs(i) &  "     key:" & Rand.NextString(8).ToLower &  "     ssid:DTTV- " & right(rs(i),7).replace(".","").ToUpper
Next
txtstr = strs

--  作者:huhu
--  发布时间:2020/8/27 13:48:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:111.jpg
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:222.jpg
图片点击可在新窗口打开查看

试了还是发现原txt没改。
[此贴子已经被作者于2020/8/27 13:49:18编辑过]

--  作者:有点蓝
--  发布时间:2020/8/27 13:51:00
--  
调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm

Dim txtstr As String = Iniwjlj & "(" & e.Form.Controls("TextBox11").text & "-" & e.Form.Controls("TextBox55").text & ")" & ".txt"
txtlj.text = lj & txtstr         \'txtljtxt这个文件怎么处理才能实现这个需求呢?
epromlj.text = lj

Dim strs As String = FileSys.ReadAllText(lj & txtstr)
msgbox(strs )
strs = strs.Replace(vblf,"")
Dim rs() As String = strs.Split(vbcr)
For i As Integer = 0 To rs.Length - 1
    strs = strs  & rs(i) &  "     key:" & Rand.NextString(8).ToLower &  "     ssid:DTTV- " & right(rs(i),7).replace(".","").ToUpper
msgbox(strs )
Next
txtstr = strs
msgbox(txtstr )

--  作者:huhu
--  发布时间:2020/8/27 14:00:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:444.jpg
图片点击可在新窗口打开查看
msgbox显示是加到了txt最后面,而不是每行增加。
另外原txt内容也没变。

--  作者:有点蓝
--  发布时间:2020/8/27 14:20:00
--  
既然知道问题了就对应解决咯

先把原来的变量值清空,再合并。或者定义一个新的变量

原txt内容,因为根本就没有把结果重新赋值回原txt的代码