gpt4 book ai didi

vb.net - 如果复选框被选中,运行 "something"

转载 作者:行者123 更新时间:2023-12-04 07:07:47 25 4
gpt4 key购买 nike

我有一个简单的 Visual Basic 2008 Express Edition 表单,如下所示:
[链接简单表格截图][1]

我需要一些有关骨架脚本的帮助,该脚本会检查是否选中了每个复选框。
我有一组 Word 模板,它们都包含一个宏。
如果模板存在,我想运行每个模板的宏。

所以基本上类似于以下内容(可能包括大量错误):

    Dim strFile1
Dim strFile2
Dim strFile3
Dim strFile4
Dim strFile5
Dim strFile6

if checkbox1.Checked Then
try to run command (Winword.exe c:\temp\document.doc /mNameOfMacro)
On error MsgBox ("could not find file from checkbox1")

if checkbox2.Checked Then
try to run command (Winword.exe c:\temp\document2.doc /mNameOfMacro)
On error MsgBox ("could not find file from checkbox2")

if checkbox3.Checked Then
try to run command (Winword.exe c:\temp\document3.doc /mNameOfMacro)
On error MsgBox ("could not find file from checkbox3")

if checkbox4.Checked Then
try to run command (Winword.exe c:\temp\document4.doc /mNameOfMacro)
On error MsgBox ("could not find file from checkbox4")


if checkbox5.Checked Then
try to run command (Winword.exe c:\temp\document5.doc /mNameOfMacro)
On error MsgBox ("could not find file from checkbox5")

if checkbox5.Checked Then
try to run command (Winword.exe c:\temp\document5.doc /mNameOfMacro)
On error MsgBox ("could not find file from checkbox5")

我知道这个伪代码根本不正确,因为我是一个初学者,设计师而不是程序员。但我刚刚开始学习,我知道这是非常基本的。
它只是对编程逻辑的概述。而且我认为开始学习如何做到这一点也会帮助我处理其他事情。

最佳答案

好的,刚刚通过这样做找到了答案:

 Dim strFile1 = ("c:\temp\file3.txt")
Dim strFile2 = ("c:\temp\file4.txt")

If chkbxRapport.Checked Then
If My.Computer.FileSystem.FileExists(strFile1) Then
System.Diagnostics.Process.Start(strFile1)
Else : MsgBox("Can't find the file" & " " & strFile1)
End If
End If

If chkbxRapport_EN.Checked Then
If My.Computer.FileSystem.FileExists(strFile2) Then
System.Diagnostics.Process.Start(strFile2)
Else : MsgBox("Can't find the file" & " " & strFile2)
End If
End If

关于vb.net - 如果复选框被选中,运行 "something",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/864767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com