Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 带两个参数的简单VB打印函数_Vba - Fatal编程技术网

Vba 带两个参数的简单VB打印函数

Vba 带两个参数的简单VB打印函数,vba,Vba,我正在寻找一个函数,它将接受两个参数(一个字符串和一个整数),并为整数的每个计数在新行上打印字符串 例如,参数(“测试”,2)将返回: test test 我相信这是一段简单的代码,但我以前从未使用过VB 非常感谢您的帮助 这种内置方法非常接近。您只需提供“打印”操作 下面是一个基本函数,它应该完成您需要的功能 Public Function printNumofTimes(text As String, number As Integer) for index = 1 to numb

我正在寻找一个函数,它将接受两个参数(一个字符串和一个整数),并为整数的每个计数在新行上打印字符串

例如,参数(“测试”,2)将返回:

test
test
我相信这是一段简单的代码,但我以前从未使用过VB


非常感谢您的帮助

这种内置方法非常接近。您只需提供“打印”操作


下面是一个基本函数,它应该完成您需要的功能

Public Function printNumofTimes(text As String, number As Integer)
    for index = 1 to number                                 
        Debug.Print text
    Next index
End Function

@康斯坦丁让我走上了正确的道路。我最终使用的代码是:

Public Function printText(text As String, number As Integer)
    dim index as integer
    dim s as string = ""
    for index = 0 to number
      if index = number
         s = s + text
      else
         s = s + text + VBCRLF
      end if
    Next index
    return s
End Function

非常感谢你。这并不完全是我所需要的,但它让我走上了正确的道路,我能够编辑你的代码来完成我所需要的。对不起,我无法提供你所需要的。但至少你到了你需要的地方。
Public Function printText(text As String, number As Integer)
    dim index as integer
    dim s as string = ""
    for index = 0 to number
      if index = number
         s = s + text
      else
         s = s + text + VBCRLF
      end if
    Next index
    return s
End Function