Re: Name function is stripping characters
- From: "Wayne Morgan" <comprev_gothroughthenewsgroup@xxxxxxxxxxx>
- Date: Sun, 23 Apr 2006 23:31:14 -0500
Do Until EOF(1)
'Grab one row's worth of data
Line Input #1, strPSFile
If InStr(strPSFile, "[5") > 0 Then
boolStop = True
End If
If InStr(strPSFile, Trim(Me.cbxSearchText.Value) & "-") > 0 Then
strPSFile = Replace(strPSFile, Trim(Me.cbxSearchText.Value & "-"),
strReplaceText)
In your code listed above, you start your loop, get the first line from the
input file, check to see if "[5" is in the string and if it is set boolStop
to True, then you replace the text that matches the combo box selection with
the replacement text you've specified. I'm guessing that if "[5" is in the
string you're wanting to not do the replacement (strictly judging by the
name of your variable boolStop); however, while you set the value of this
variable to True, you then never do anything with it. It is not used in any
If statement or anything else in this procedure that would cause your code
to "stop" doing what it's doing. I also noticed that boolStop was NOT Dim'ed
in this procedure, so you may be using the value of it elsewhere, but I
can't tell that by what you have here.
I would recommend commenting out the Name line in the code and checking the
contents of the file TEMP2*. This will let you see what its contents are
before it gets renamed.
ImportError:
MsgBox Err.Description
Label3.ForeColor = vbRed
Label3.Caption = "Error!"
Close #1
GoTo Done
Unless you're trying to keep Err dirty for some reason, the last line should
be
Resume Done
instead of
GoTo Done
although, the error should clear when you exit the procedure anyway. So it
may just be a technicality.
--
Wayne Morgan
MS Access MVP
"mcnewsxp" <mcourter@xxxxxxxxxxxxxx> wrote in message
news:u6PL15vZGHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
Private Sub ImportPSFile(sTxtInFile As String)
'''label vars
Dim strPSFile As String
'''marker vars
Dim fso As New FileSystemObject, fil1
Dim strReplaceText As String
Dim txtFile
Dim strCmd As String
Screen.MousePointer = 11
Label3.ForeColor = vbBlack
Label3.Caption = "Formatting..."
DoEvents
On Error GoTo ImportError
stringDataPath = Application.CurrentProject.Path & "\"
If Dir(stringDataPath & "\NEW" & sTxtInFile) <> "" Then
Kill stringDataPath & "\NEW" & sTxtInFile
End If
If Dir(stringDataPath & "\TEMP" & sTxtInFile) <> "" Then
Open stringDataPath & "\TEMP" & sTxtInFile For Input As #1
Set txtFile = fsoOut.CreateTextFile(stringDataPath & "TEMP2" &
sTxtInFile, True)
Else
Open stringDataPath & "\" & sTxtInFile For Input As #1
Set txtFile = fsoOut.CreateTextFile(stringDataPath & "TEMP" &
sTxtInFile, True)
End If
Select Case Me.cbxReplaceText.Value
Case Is = "Black"
strReplaceText = "1 1 1 setrgbcolor " & vbCrLf &
Me.cbxSearchText.Value & "-"
Case Is = "Blue"
strReplaceText = "0 0 1 setrgbcolor" & vbCrLf &
Me.cbxSearchText.Value & "-"
Case Is = "Dark Gray"
strReplaceText = "0.7 0.7 0.7 setrgbcolor " & vbCrLf &
Me.cbxSearchText.Value & "-"
Case Is = "Gray"
strReplaceText = "0.5 0.5 0.5 setrgbcolor " & vbCrLf &
Me.cbxSearchText.Value & "-"
Case Is = "Red"
strReplaceText = "1 0 0 setrgbcolor " & vbCrLf &
Me.cbxSearchText.Value & "-"
Case Is = "Violet"
strReplaceText = "1 0 1 setrgbcolor " & vbCrLf &
Me.cbxSearchText.Value & "-"
End Select
Do Until EOF(1)
'Grab one row's worth of data
Line Input #1, strPSFile
If InStr(strPSFile, "[5") > 0 Then
boolStop = True
End If
If InStr(strPSFile, Trim(Me.cbxSearchText.Value) & "-") > 0 Then
strPSFile = Replace(strPSFile, Trim(Me.cbxSearchText.Value & "-"),
strReplaceText)
txtFile.WriteLine (strPSFile)
Line Input #1, strPSFile
Else
txtFile.WriteLine (strPSFile)
End If
Loop
Close #1
Set txtFile = Nothing
If Dir(stringDataPath & "\TEMP2" & sTxtInFile) <> "" Then
Kill stringDataPath & "\TEMP" & sTxtInFile
Name stringDataPath & "\TEMP2" & sTxtInFile As stringDataPath &
"\TEMP" & sTxtInFile
End If
Label3.Caption = "Done!"
Done:
Screen.MousePointer = 0
Exit Sub
ImportError:
MsgBox Err.Description
Label3.ForeColor = vbRed
Label3.Caption = "Error!"
Close #1
GoTo Done
End Sub
.
- Follow-Ups:
- Re: Name function is stripping characters
- From: mcnews
- Re: Name function is stripping characters
- From: mcnews
- Re: Name function is stripping characters
- References:
- Name function is stripping characters
- From: mcnewsxp
- Re: Name function is stripping characters
- From: Wayne Morgan
- Re: Name function is stripping characters
- From: mcnewsxp
- Re: Name function is stripping characters
- From: Wayne Morgan
- Re: Name function is stripping characters
- From: Wayne Morgan
- Re: Name function is stripping characters
- From: mcnewsxp
- Re: Name function is stripping characters
- From: Wayne Morgan
- Re: Name function is stripping characters
- From: mcnewsxp
- Re: Name function is stripping characters
- From: Wayne Morgan
- Re: Name function is stripping characters
- From: mcnewsxp
- Name function is stripping characters
- Prev by Date: Re: referential integrity
- Next by Date: Re: Converting a 2003 database to an earlier version
- Previous by thread: Re: Name function is stripping characters
- Next by thread: Re: Name function is stripping characters
- Index(es):