首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Visual Basic button.click如何返回If

Visual Basic button.click如何返回If
EN

Stack Overflow用户
提问于 2019-12-26 04:26:10
回答 1查看 83关注 0票数 0

我有一个问题,我想在按下按钮后程序检查是否有文件在不同的位置(我使用的是if),如果这个文件不存在,我会下载它们(否则),下载后我会回到if并继续其余的代码。

代码语言:javascript
复制
If ComboBox2.SelectedItem = "1.12.2 Release" Then
    If My.Computer.FileSystem.DirectoryExists(natives & "\1.12.2\natives") Then
        launch = ("START CODE")
        Shell("cmd.exe @echo off /c" & launch)
        Me.Close()
    Else
        My.Computer.Network.DownloadFile("MY URL/natives.zip", natives & "\1.12.2\natives.zip")
        System.IO.Compression.ZipFile.ExtractToDirectory(natives & "\1.12.2\natives.zip", natives & "\1.12.2")
        My.Computer.FileSystem.DeleteFile(natives & "\1.12.2\natives.zip")
        Return

我想要在这段代码中添加更多内容,我想先做这件事,然后我留在了这里。在代码中,我只能看到5-7个要检查的文件夹中的一个

EN

回答 1

Stack Overflow用户

发布于 2019-12-26 04:55:30

创建以下逻辑

代码语言:javascript
复制
sub Main()
    if not CheckFolders() then
        if not DownloadFolders() then
            MessageBox.Show("Can't start program")
            Return
        end if
    end if

    ' Start your program here
end sub


function CheckFolders() as boolean
    ' check your folders here
end function

function DownloadFolders() as boolean
    ' download your folders here
end function

这样,您就可以将检查文件/文件夹的逻辑与下载和启动逻辑分开。并且您可以按您希望的方式操作每个单独的组件

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59481628

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档