Wol*_*ves 8 vb.net arrays vba list sortedlist
我在VB.NET中写作非常新,我甚至没有意识到VB.NET和VBA之间存在显着差异.我一直在Visual Studio中编写我的应用程序,但我意识到我需要将它移植到Outlook中的VBA,并且我需要处理一些语法问题.我已经搜索过,但是我找不到VBA甚至VB6的任何明确的引用(比如msdn),从我听到的内容比VB.NET更接近VBA.
我将在此处包含相关的代码部分.如果有人需要更多的背景,请让我知道 - 我可以发布整个事情,它不是那么久.不过,我想让这篇文章尽可能简单.
Dim DateToday As String = String.Format("0:{yyyy/MM/dd}", DateTime.Now)
Dim Computers As New SortedList()
Dim disabledList As New List(Of String)
'\\ four additional lists
Dim compArray As Array
...
Computers.Add(ComputerName, ErrorState)
新列表和排序列表在List之后的括号中给出Expected:Statement of Statement.该数组在Array中给出Expected:identifier.字符串DateToday在等号处给出了预期的语句结束.添加到排序列表的尝试给出了Expected:=.
我一直在使用VB.NET大概两三天,之前我从未使用过VBA或VB6,所以我只是没有必要的经验知道从哪里开始.如果你们中的任何一个愿意帮助我,我会非常感激!
Rip*_*ter 13
您将不得不更改某些数据类型,但鉴于我使用的数据类型可能不准确,您刚刚发布的内容的基础知识可能会转换为与此类似的内容.
Dim DateToday As String: DateToday = Format(Date, "yyyy/MM/dd")
Dim Computers As New Collection
Dim disabledList As New Collection
Dim compArray(1 To 1) As String
'Assign data to first item in array
compArray(1) = "asdf"
'Format = Item, Key
Computers.Add "ErrorState", "Computer Name"
'Prints "ErrorState"
Debug.Print Computers("Computer Name")
无法对集合进行排序,因此如果需要对数据进行排序,则可能需要使用数组.
这是outlook开发人员参考的链接. http://msdn.microsoft.com/en-us/library/office/ff866465%28v=office.14%29.aspx
另一个帮助您入门的好网站是 http://www.cpearson.com/Excel/Topic.aspx
将所有内容从VB.Net移到VBA并不简单,因为并非所有数据类型都相同,并且您没有.Net框架.如果您遇到问题,只需发布代码即可转换,您一定会得到一些帮助!
编辑:
Sub ArrayExample()
    Dim subject As String
    Dim TestArray() As String
    Dim counter As Long
    subject = "Example"
    counter = Len(subject)
    ReDim TestArray(1 To counter) As String
    For counter = 1 To Len(subject)
        TestArray(counter) = Right(Left(subject, counter), 1)
    Next
End Sub
| 归档时间: | 
 | 
| 查看次数: | 99449 次 | 
| 最近记录: |