Private Sub Command1_Click()
ReplaceDoubleSpace (Text1.Text)
End Sub
Private Function ReplaceDoubleSpace(ByVal str As String) As String
Dim r As String
r = Replace(str, Space(2), Space(1))
Dim m, n
Do
m = Len(r)
r = Replace(r, Space(2), Space(1))
n = Len(r)
Loop Until m = n
ReplaceDoubleSpace =r
End Function
vb中怎样把字符串中的多个空格合并成一个空格
Private Function MyTrim(s As String) As String MyTrim = Trim(s) '去掉首尾空格 Do While InStr(1, MyTrim, " ") > 0 '循环直到检查到没有两个连续的空格 MyTrim = Replace(MyTrim, " ", " ")Loop End Function Private Sub Command1_Click()Dim s As String s = " a ...
用VB将字符串中的多个连续空格合并成一个空格,同时删去第一个字符前...
Private Sub Command1_Click() Dim strS As String strS = InputBox("请输入字符串", "", " a bcd ef ghij k lmn ") Label1.Caption = strS strS = Trim(strS) Do While ContinuousSpace(strS) For i = 1 To Len(strS) - 1 If Mid(strS, ...
vb初级问题●怎样能将一段文字中一些连续的若干空格合并成一个
Dim s As String Dim i As Integer Dim length As Integer Dim str As String s = txt.Text length = Len(s)length = length - 1 For i = 1 To length If Not (Mid(s, i, 1) = Chr(32) And Mid(s, i + 1, 1) = Chr(32)) Then '没有出现连续的空格,将该字符赋值给str...
VB中如何把多个字符串组合到一起?
用字符连接符阿 & 或者 + 如:变量名="日期:"&"4\/10"变量名就为: “日期:4\/10”d是变量名么?也可以直接加啊 不加引号就可以了 新变量名=d & "日期"产生的结果是:新变量名= d的值符 日期 不会有空格吧?仔细看看你先前定义的变量里面是不是加空格了?有的话去掉就可以了 ...
...将s中的前导空格和尾随空格删去,中间连续多个空格缩减为一个空_百度...
去掉前后空格用Trim(),中间的空格麻烦点,要逐个字符分析 Dim c As String * 1 Dim strResult As String Dim b As Boolean, i As Long For i = 1 To Len(s)c = Mid(s, i, 1)If c = " " Then If Not b Then strResult = strResult & c b = True End If Else strResult =...
vb6.0如何实现文本框中每输入4个字符插入1个空格?
Private Sub Command1_Click()Dim a As String Dim b As String Dim i As Long a = "1234i5tr6u75u9ir8ew9w"b = Left$(a, 4)For i = 1 To Len(a) \/ 4 b = b & " " & Mid$(a, i * 4 + 1, 4)Next i text1.text =b End Sub ...
vb 把字符串里的空格有长有短,空格是连续的,如3个连续半角空格转换为...
用一个Replace函数就替换完成了:S=" v 6维吾尔 sdsdfffs ‘ ?"S = Replace(S, " ", " ") '半角空格替换为全角空格 以下是我再次作的试验:Private Sub Command1_Click()Open "d:\\111.txt" For Output As #1 s = " v 6维吾尔 sdsdfffs ‘ ...
vb 字符串转数组问题
Do While InStr(str1, " ") str1 = Replace(str1, " ", " ") Loop 大概是这个意思吧 就是把STR1这个字符串中所有 两个空格或者两个以上的空格 都变成一个空格
VB.net 中, 输入“空格”的代码
textbox.text = "12345" & " " & "67890"或者 textbox.text = "12345" & space(1) & "67890"
VB如何将指定文本的换行符替换成空格?
Private Sub Command1_Click() Dim fso As Object, fs As Object Set fso = CreateObject("scripting.Filesystemobject") Dim s As String, ss As String ss = app.path & "\\abc.txt" Set fs = fso.opentextfile(ss) '打开文件 s = fs.readall '读取所有文本 ...