从字符串“,"的转换键入“布尔"无效 [英] Conversion from string "," to type 'Boolean' is not valid
本文介绍了从字符串“,"的转换键入“布尔"无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
能否请我帮忙,导致我在此代码中出现从字符串转换为",键入"Boolean"无效"的错误..
Hello guys,
Can you please help me please, cause i''m having an error on "Conversion from string "," to type ''Boolean'' is not valid" in this code..
Public Sub LoadUsers()
Dim LI As ListViewItem
Dim Users(), Napa() As String
Dim Data As String
Dim Path As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\encoders.dat"
Dim i As Integer
lvUsers.Items.Clear()
Data = LoadFile(Path)
If Data = "" Then Exit Sub
Users = Split(Data, ",")
For i = 0 To UBound(Users)
Napa = Split(Users(i), "=")
LI = lvUsers.Items.Add(Napa(0))
LI.SubItems.Add(Napa(1))
Next i
End Sub
并且在"Users = Split(Data,,")行中发生错误
请帮我吧...
在此先感谢....
And error occurs in the line of " Users = Split(Data, ",")"
Please hep me guys....
Thanks in advance....
推荐答案
使用
Use
Users = Split(Data, ","c)
或
or
Users = Split(Data, '','')
Split是Data
的一种方法,它是一个字符串.Data
不能是第一个参数.另外,定界符参数是字符数组,而不是字符串.
您不应使用",而应使用string.Empty
.
阅读 http://msdn.microsoft.com/en-us/library/system.string .split.aspx [ ^ ].
—SA
Split is a method ofData
which is a string.Data
cannot be a first parameter. Also, delimiter parameter is array of characters, not string.
You should not use "", usestring.Empty
.
Read http://msdn.microsoft.com/en-us/library/system.string.split.aspx[^].
—SA
Split
函数中的第二个参数是int或StingSplit
options枚举,因此,"无效.
The second parameter in theSplit
function is either an int or aStingSplit
options enumeration, so "," is invalid.
这篇关于从字符串“,"的转换键入“布尔"无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文