Dim StateNmList() As String, StateName As Object
StateNmList = ("Alabama", "Alaska", "Arizona", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia","Hawaii", "Idaho", "Illinios", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi","Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma","Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia","Wisconsin", "Wyoming")
StateName = Split(StateNmList, ",")
Return StateName
返回错误: BC30311'String'类型的值不能转换为'String()' BC30311'String()'类型的值不能转换为'String'。
我不确定我做错了什么。
答案 0 :(得分:0)
Split用于将单个字符串分隔为字符串数组,如下所示(未经测试):
dim StateNameString as string
dim StateNameArray() as string
StateNameString = "Oklahoma, Arkansas, Hawaii, ..."
StateNameArray = StateNameString.Split(",")
for each stateName as string in stateNameArray
msgbox (stateName)
next stateName