suppose i have a text file in which its words should be separated by one space only, and i don't want some one to cheat by inserting other spaces, i know there is a regular expression solution for such cases, but i prefer a ready to use functions
this is my approach using a string instead of a file, it seems to work, other solutions is appreciated.
also why the text in the TextBox selected ?
Uses "UI"
Begin ControlID
%ID_TextBox2
End ControlID
Function TBMain()
Dim hDlg, i As Long
Dim stringo As String
stringo = "Goto (goto , GOTO , GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages. It performs a one-way transfer of control to another line of code"
For i=1 To 100
stringo = Replace$(stringo, " ", " ")
If InStr(1, Stringo, " ") = 0 Then
Exit For
End If
Next
'msgbox 0, str$(i)
Dialog New 0, "replace many spaces to one space", -1, -1, 500, 400, _
%WS_DLGFRAME Or %DS_CENTER Or %WS_CAPTION Or %WS_SYSMENU, _
0 To hDlg
Control Add Textbox , hDlg, %ID_TextBox2, "test" , 5, 25, 450, 310, %ES_WANTRETURN Or _
%ES_MULTILINE Or _
%ES_AUTOVSCROLL Or _
Control Append Text hDlg, %ID_TextBox2, $CRLF & stringo & $CRLF
'---Show dialog in MODAL
Dialog Show Modal hDlg, Call dlgCallback
End Function
CallBack Function dlgCallback() As Long
Select Case CBMSG
Case %WM_CLOSE
End Select
End Function
EDIT:
this is a better solution:
replace:
For i=1 To 100
stringo = Replace$(stringo, " ", " ")
If InStr(1, Stringo, " ") = 0 Then
Exit For
End If
Next
with:
Repeat
stringo = Replace$(stringo, " ", " ")
Until InStr(1, Stringo, " ") = 0
Bookmarks