我如何在VB.NET中调用方法 [英] How I call method in VB.NET

查看:108
本文介绍了我如何在VB.NET中调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我用vb.net开发的应用程序中,我有3个方法

第一个:函数first()作为父参考

第二个:函数第二个(父参考) )作为父母参考

第三个:第三个(父级参考)



按钮事件,经过测试(如果),我想打电话给那些方法



我的意思是,当(例如)我先打电话时,我想确切地知道返回这个méthod的价值



在我的代码中(在事件按钮中),我这样做:



 dim ref作为父参考
dim res作为父参考
ref = first()
res = second(ref)





但总是结果是假的



 Dim ref作为ParentReference'参考文件夹')
'参考sous档案
Dim res作为ParentReference'引用子文件夹

如果(exists(folder_name.selectindex)= True)那么
Messag eBox.Show(Exist文件夹,Vérify子文件夹)

这里我调用创建子文件夹(我需要文件夹参考)







文件夹,子文件夹和文件都在谷歌驱动器



我尝试过:



i必须尝试从事件按钮调用方法

解决方案

这应该得到你开始了:

 模块 Module1 

Sub Main()

Dim ParentFolder As 字符串 = My.Computer.FileSystem.SpecialDirectories.MyDocuments
Dim ChildFolder As String = NewChildFolder

CreateFolder(ParentFolder,ChildFolder)
结束 Sub

私有 Sub CreateFolder(ParentFolder 作为 字符串,ChildFolder 作为 String

Dim FolderPath = IO.Path.Combine(ParentFolder,ChildFolder)

如果 IO.Directory.Exists(FolderPath)那么
MkDir(FolderPath)
结束 如果
结束 Sub

结束 < span class =code-keyword >模块





更新 - GOOGLE DRIVE



您已经在Google云端硬盘上提出了几个问题。回顾:

* 文件夹存在 - 如果文件夹存在与否如何找到 [ ^ ]

* 上传文件 - 如何在Google云端硬盘VB.NET中的特定文件夹中插入文件 [ ^ ]



Google Drive API文档包含创建文件夹的.Net代码使用文件夹  | 推动REST API  |  Google Developers [ ^ ]



直接从Google Drive API文档中复制:

  var  fileMetadata =  new 文件()
{
Name = 发票
MimeType = application / vnd.google-apps.folder
};
var request = driveService.Files.Create(fileMetadata);
request.Fields = id;
var file = request.Execute();
Console.WriteLine( 文件夹ID: + file.Id);


In my application developped with vb.net , i have 3 Method
the first : function first () as parent reference
the second : function second (parent reference ) as parent reference
the third : sub third (parent reference)

in the button event , after a test (if) , i want to call those method

I mean , when (for example) i call first , i want to know exactly the value which return this méthod

in my code (in event button ) , i do :

dim ref as parent reference
dim res as parent reference 
ref= first()
res = second(ref) 



but always the result is false

Dim ref As ParentReference ' reference folder ')
      'reference sous dossier
      Dim res As ParentReference ' reference subfolder

      If (exist(folder_name.selectindex) = True) Then
          MessageBox.Show("Exist folder , Vérify subfolder")

                   here i call creation subfolder (i need folder reference exactly)




folder , subfolder and file are in google drive

What I have tried:

i have to tried to call a method from event button

解决方案

This should get you started:

Module Module1

    Sub Main()

        Dim ParentFolder As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        Dim ChildFolder As String = "NewChildFolder"

        CreateFolder(ParentFolder, ChildFolder)
    End Sub

    Private Sub CreateFolder(ParentFolder As String, ChildFolder As String)

        Dim FolderPath = IO.Path.Combine(ParentFolder, ChildFolder)

        If Not IO.Directory.Exists(FolderPath) Then
            MkDir(FolderPath)
        End If
    End Sub

End Module



UPDATE - GOOGLE DRIVE

You have already asked several questions on Google Drive. To recap:
* Folder Exists - How to found if folder exist or not[^]
* Upload File - How to insert a file in specific folder in Google drive VB.NET[^]

Google Drive API documentation has .Net code for Creating a folder: Work with Folders  |  Drive REST API  |  Google Developers[^]

Copied directly from the Google Drive API documentation:

var fileMetadata = new File()
{
    Name = "Invoices",
    MimeType = "application/vnd.google-apps.folder"
};
var request = driveService.Files.Create(fileMetadata);
request.Fields = "id";
var file = request.Execute();
Console.WriteLine("Folder ID: " + file.Id);


这篇关于我如何在VB.NET中调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆