Advertisement
Advertisement
| 03.06.2008 at 06:13PM PST, ID: 23221861 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 03.06.2008 at 07:04PM PST, ID: 21066996 |
| 03.06.2008 at 07:10PM PST, ID: 21067035 |
| 03.06.2008 at 07:25PM PST, ID: 21067092 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: |
Dim handle As Integer
Dim outhandle As Integer
Dim infilename As String
Dim outfilename As String
Dim buffer As String
infilename = "MyOriginalTextFile.txt"
outfilename = "ConvertedTextFile.txt"
handle = FreeFile
Open infilename For Input As handle
outhandle = FreeFile
Open (outfilename) For Output As outhandle
Do While EOF(handle) = False
Line Input #handle, buffer
Do While InStr(buffer, " ") > 0
buffer = Replace(buffer, " ", " ")
Loop
Print #outhandle, buffer
Loop
Close (handle)
Close (outhandle)
|
| 03.06.2008 at 08:18PM PST, ID: 21067312 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: |
Option Explicit
Sub CleanUpFile()
Dim fso As Object, ts As Object, WholeFile As String
Const filepath As String = "c:\folder\subfolder\file.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(filepath)
WholeFile = ts.ReadAll
ts.Close
Set ts = fso.CreateTextFile(filepath, True)
ts.Write RegExpReplace(WholeFile, " {2,}")
ts.Close
Set ts = Nothing
Set fso = Nothing
MsgBox "Done"
End Sub
Function RegExpReplace(LookIn As String, PatternStr As String, Optional ReplaceWith As String = "", _
Optional ReplaceAll As Boolean = True, Optional MatchCase As Boolean = True)
' This function uses Regular Expressions to parse a string, and replace parts of the string
' matching the specified pattern with another string. The optional argument ReplaceAll controls
' whether all instances of the matched string are replaced (True) or just the first instance (False)
' By default, RegExp is case-sensitive in pattern-matching. To keep this, omit MatchCase or
' set it to True
' If you use this function from Excel, you may substitute range references for all the arguments
Dim RegX As Object
Set RegX = CreateObject("VBScript.RegExp")
With RegX
.Pattern = PatternStr
.Global = ReplaceAll
.IgnoreCase = Not MatchCase
End With
RegExpReplace = RegX.Replace(LookIn, ReplaceWith)
Set RegX = Nothing
End Function
|
| 03.06.2008 at 08:21PM PST, ID: 21067324 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: |
Option Explicit
Sub CleanUpFile()
Dim fso As Object, ts1 As Object, ts2 As Object
Const InputFile As String = "c:\folder\subfolder\file.txt"
Const OutputFile As String = "c:\folder\subfolder\clean_file.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts1 = fso.OpenTextFile(InputFile)
Set ts2 = fso.CreateTextFile(OutputFile)
Do Until ts1.AtEndOfStream
ts2.WriteLine RegExpReplace(ts1.ReadLine, " {2,")
Loop
ts1.Close
ts2.Close
Set ts1 = Nothing
Set ts2 = Nothing
Set fso = Nothing
MsgBox "Done"
End Sub
Function RegExpReplace(LookIn As String, PatternStr As String, Optional ReplaceWith As String = "", _
Optional ReplaceAll As Boolean = True, Optional MatchCase As Boolean = True)
' This function uses Regular Expressions to parse a string, and replace parts of the string
' matching the specified pattern with another string. The optional argument ReplaceAll controls
' whether all instances of the matched string are replaced (True) or just the first instance (False)
' By default, RegExp is case-sensitive in pattern-matching. To keep this, omit MatchCase or
' set it to True
' If you use this function from Excel, you may substitute range references for all the arguments
Dim RegX As Object
Set RegX = CreateObject("VBScript.RegExp")
With RegX
.Pattern = PatternStr
.Global = ReplaceAll
.IgnoreCase = Not MatchCase
End With
RegExpReplace = RegX.Replace(LookIn, ReplaceWith)
Set RegX = Nothing
End Function
|
| 03.07.2008 at 04:38AM PST, ID: 21069373 |
| 03.07.2008 at 05:27AM PST, ID: 21069716 |
| 03.07.2008 at 07:46AM PST, ID: 21071244 |
| 03.07.2008 at 07:52AM PST, ID: 21071319 |
| 03.07.2008 at 08:14AM PST, ID: 21071589 |