vb.net以msg为单位的每个空间 [英] vb.net for each space in msg

查看:84
本文介绍了vb.net以msg为单位的每个空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我有这个代码:
< pre lang ="vb">
昏暗的RandomNumber作为新的Random()
Dim msg As String =我的名字是海王星的尼克"
</pre>
而且我想用随机数替换味精中的每个空格,这样听起来像
My12name455is22Nick88from66Neptune

有人可以帮我吗?

在此先感谢您,并感谢我的英语

Hy, I have this code :
<pre lang="vb">
Dim RandomNumber As New Random()
Dim msg As String = "My name is Nick from Neptune"
</pre>
and I want to replace each space from msg with random numbers so it will sound like this
My12name455is22Nick88from66Neptune

Can anyone help me with this?

Thanks in advance and sorry for my English

推荐答案

您想要实现的目标很容易实现.
在字符串上运行while循环,直到找到空格为止(使用IndexOf).
直到您一直保持空白,然后用随机数替换.

看看String.Replace 方法 [
What you are trying to achieve is easy to implement.
Run a while loop on the string until spaces are found (using IndexOf).
Till you keep getting a blank, replace with a random number.

Have a look at the String.Replace method[^].

Pseudo code would look like -
while (s.IndexOf('' '') != -1)<br />
{<br />
   s.Replace('' '' ,RandomNumber.ToString();<br />
}


嗨Abhinav S
我正在使用MVS2010,并且该程序是在Windows Forms中构建的.
感谢您的帮助,但无法使用.
如果您可以将上述脚本转换为Windows窗体,我将非常高兴.
预先感谢
Hy Abhinav S
I am using MVS2010 and the program is build in windows Forms
Thanks for your help but is does not work.
I will be very happy if you could convert the above script for Windows Forms.
Thanks in advance


这篇关于vb.net以msg为单位的每个空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆