十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Dim a(20) As String
创新互联建站专业为企业提供秀洲网站建设、秀洲做网站、秀洲网站设计、秀洲网站制作等企业网站建设、网页设计与制作、秀洲企业网站模板建站服务,十多年秀洲做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
Dim num As Integer
Dim ppp As String = ""
Dim temp As String = ""
For i = 1 To 20
temp = ""
num = Int(Rnd() * 10 + 1)
For j = 1 To num
temp = temp Chr(Int(Rnd() * 26 + 97))
Next
a(i) = temp
Next
Dim max As Integer = 0
For i = 1 To 20
If a(i).Length max Then
max = a(i).Length
End If
Next
For i = 1 To 20
If a(i).Length = max Then
ppp = ppp "字符最多的元素是第" i "个元素" a(i) vbCrLf
End If
Next
For i = 1 To 20
TextBox1.Text = TextBox1.Text a(i).PadRight(10) " "
If i Mod 4 = 0 Then
TextBox1.Text = TextBox1.Text vbCrLf
End If
Next
TextBox1.Text = TextBox1.Text ppp
字符串的操作应用
[vb]
Module Module
Sub Main()
定义 个字符串变量
Dim str str str As String
给str str 付初值
str = Hello : str = World
Console WriteLine( 方法Concat )
连接一个或多个字符串
Console WriteLine( str ={ } str ={ } String Concat(str str )={ } str str String Concat(str str ))
判断字符串中是否具有相同的值返回类型为布尔型
Console WriteLine( 方法Equals )
Console WriteLine( str ={ } str ={ } String Equals(str )={ } str str str Equals(str ))
在字符串中指定索引位置插入指定的字符串
Console WriteLine( 方法Insert )
str = : str = aaa
Console WriteLine( str ={ } str ={ } str Insert( str )={ } str str str Insert( str ))
左右对齐字符串中的字符
Console WriteLine( 方法PadLeft/PadRight )
str = World : str = 世界
Console WriteLine( str ={ } str )
Console WriteLine( str PadLeft( * )={ } str PadRight( * )={ } str PadLeft( * ) str PadRight( * ))
Console WriteLine( str ={ } str )
Console WriteLine( str PadLeft( * )={ } str PadRight( * )={ } str PadLeft( * ) str PadRight( * ))
找出指定字符串或字符转在此字符串中的第一个 最后一个匹配项的索引位置
Console WriteLine( 方法IndexOf/LastIndexOf )
str = Visual Basic NET ASP NET C# NET
Console WriteLine( str ={ } str )
Console WriteLine( str IndexOf( NET )={ } str LastIndexOf( NET )={ } str IndexOf( NET ) str LastIndexOf( NET ))
将字符串中的字符复制到字符串数组
Console WriteLine( 方法ToCharArray )
str = str ToCharArray(str IndexOf( NET ) )
Console WriteLine( str ={ } str )
Console WriteLine( str ToCharArray(str IndexOf( NET ) )={ } str )
在指定字符串数组的每个元素之间串联指定的分隔符 产生单个串联的字符串
Console WriteLine( 方法Join )
Dim myArray( ) As String
myArray( ) = I : myArray( ) = am : myArray( ) = a : myArray( ) = student
For i As Integer = To
Console Write( myArrat({ })={ } i myArray(i))
Next
Console WriteLine()
Console WriteLine( String Join( * myArray)={ } String Join( * myArray))
此字符串中删除指定个数字符
Console WriteLine( 方法Remove )
str =
Console WriteLine( str ={ } str Remove( )={ } str str Remove( ))
将此字符串指定字符串字符的所有匹配项代替为其他指定字符串
Console WriteLine( 方法Replace )
str =
str = abc
Console WriteLine( str ={ } str ={ } str ={ } str Replace(str str )={ } str str str str Replace(str str ))
从此字符串检索字符串
Console WriteLine( 方法SubString )
Console WriteLine( str ={ } str Substring( )={ } str str Substring( ))
Console ReadLine()
End Sub
lishixinzhi/Article/program/net/201311/13956
vb点虐 已经去掉了控件数组这个类,不过有个代替该方式的一个属性:tag,你可以把这些关联的tag属性设置为同一标记,如:a。然后遍历所有的checkbox并且tag为a的则选定:
protected
sub
chkall_click()
for
each
ctl
as
control
in
me.controls
''如果checkbox在一个容器里,比如groupbox,那可以用groupbox.controls
if
ctl.gettype().name.tolower()
=
"checkbox"
then
ctype(ctl,
checkbox).checked
=
checkbox3.checked
end
if
next
end
sub
1。动态数组 dim myStr() as string
2。固定数组 dim myStr(10) as string
3。net字符串数组 dim myStr as string()
都差不多的。