【发布时间】:2021-06-27 15:01:30
【问题描述】:
我是 VBA 新手,所以我想将输入框中的值存储到数组中,我编写了下面的代码,然后我尝试定义一个数组来存储它们,我的 VBA 代码有问题,请问帮忙查一下?任何帮助将不胜感激
Sub inpubox()
Dim sn As String
Dim em_ID As String
Dim name As String
Dim dept As String
Dim hostname As String
Dim loc As String
sn = InputBox("Enter Laptop's Serial")
em_ID = InputBox("Enter Colleague ID")
name = InputBox("Enter Colleague Name")
dept = InputBox("Enter Colleague department")
loc = InputBox("Enter office location")
'Xu li hostname
hostname = "VN" & loc & sn
sodong = Sheet1.Range("A" & Rows.Count).End(xlUp).Offset(1).row
Dim arr6 As String
arr6 =(sn,em_id,name,dept,hostname,loc)
End Sub
【问题讨论】:
-
尝试 ..
arr6 = split(sn&","&em_ID&","&name&","&dept&","&hostname&","&loc, ",").. 这将为您提供基于 0 的 arr6 -
您将 arr6 定义为字符串。您需要将其定义为数组
-
Yes..
Dim arr6() As String会给你字符串类型的数组。
标签: vba