打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
VB.Net Split的4种使用方法
4个关于split的实例

1. 简单的split分割字符串

首先我们拿了一个带多个空格的字符串来做分割. 我们分配一个New Char() array 保存为String() array 来储存我们例子中的那些分割后的单词.最后,我们用loop循环来遍历和显示这些分割后的字母集合.

=== Program that uses Split on String (VB.NET) ===Module Module1
Sub Main()' We want to split this input stringDim s As String = "Our website address is www.lob.cn"' Split string based on spacesDim words As String() = s.Split(New Char() {" "c})' Use For Each loop over words and display themDim word As String
For Each word In words
Console.WriteLine(word)
Next
End Sub
End Module=== Output of the program ===Our
website
address
is
www.lob.cn

2. 分割一个完整文件路径

Here we see how you can Split a file system path into separate parts using Visual Basic .NET. We use a New Char() array with one string, "\""c, and then loop through and display the results.

=== Program that splits file path (VB.NET) ===Module Module1
Sub Main()' The file system path we need to splitDim s As String = "C:\Users\Sam\Documents\Perls\乐博网"' Split the string on the backslash characterDim parts As String() = s.Split(New Char() {"\"c})' Loop through result strings with For EachDim part As String
For Each part In parts
Console.WriteLine(part)
Next
End Sub
End Module=== Output of the program ===C:
Users
Sam
Documents
Perls
乐博网
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
vb.net split字符串分割函数的用法
VB.NetDictionary的技巧和8个实例
VB.net与C#语法对比及转换
VB.NET字节数组用法
VB.NET 拆分、合并PDF工具(PDF批量打印)
在vb.net 中调用oracle数据库
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服