怎么把生成的文本自动生成到指定文件夹内???
代码如下简写:
Dim Snow(1000, 2), Amounty As Integer
Private Sub Command1_Click()
dmlt = dmlt + " aaaa"
dmlt = dmlt + "" + vbCrLf
dmlt = dmlt + " m4=""down""" + vbCrLf
dmlt = dmlt + " m5=""file""" + vbCrLf
dmlt = dmlt + " m6=""copy""" + vbCrLf
dmlt = dmlt + " m7=""exit""" + vbCrLf
dmlt = dmlt + " " + Text1.Text + ""
Open App.Path & "\" & "Ms.TXT" For Output As #1
Print #1, dmlt
Close #1
End Sub
------------------------
这样生成的一个文本会在当前目录下生成个MS.TXT的文本。。现在我需要的是建立多个Command1_Click()按钮,点击该按钮后则文本生成到C:盘,点另外个按钮则生成到D:盘。。这怎么做到呢?
[解决办法]
大概明白你的意思,看看是不是这样:
1.添加5个按钮,分别是Command1~5,然后添加如下代码:
Private CheckPaths As StringPrivate Sub Form_Load()Command1.Caption="生成文件"Command2.Caption="C:\"Command3.Caption="D:\"Command4.Caption="E:\"Command5.Caption="F:\"End SubPrivate Sub Command1_Click()Open CheckPaths & "AA.txt" For OutPut As #1Print #1,"a"'a是你要写入的内容Close #1End SubPrivate Sub Command1_Click()CheckPaths =Command1.CaptionEnd SubPrivate Sub Command2_Click()CheckPaths =Command2.CaptionEnd SubPrivate Sub Command3_Click()CheckPaths =Command3.CaptionEnd SubPrivate Sub Command4_Click()CheckPaths =Command4.CaptionEnd SubPrivate Sub Command5_Click()CheckPaths =Command5.CaptionEnd Sub