gpt4 book ai didi

windows - 字符串中每个空格的 VB.NET Windows 窗体

转载 作者:可可西里 更新时间:2023-11-01 10:28:07 24 4
gpt4 key购买 nike

嘿,我有这个代码

Dim RandomNumber As New Random()
Dim msg As String = "My name is Nick from Neptune"
For each space as char in msg
msg = msg.replace(" ", RandomNumber.Next(0, 33))
Next

但它不起作用。有人能帮我吗?最后的字符串应该是这样的:

My12name455is22Nick88from66Neptune

提前致谢,抱歉我的英语不好。

最佳答案

我把它改成了工作,我很抱歉:

Option Infer On

Module Module1

Sub Main()
Dim RandomNumber As New Random()
Dim msg As String = "My name is Nick from Neptune"
Dim newmessage As String = ""
Dim d = msg.Split(" ").ToList()

For Each t In d
newmessage = newmessage & Convert.ToString(t) & RandomNumber.[Next](0, 33).ToString()
Next

Console.WriteLine(newmessage)
End Sub

结束模块

enter image description here

关于windows - 字符串中每个空格的 VB.NET Windows 窗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7976672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com