|
-
Aug 29th, 2000, 04:35 PM
#1
Thread Starter
Lively Member
Hopefully this will be an easy one for all you VB Gurus out there.
I Have a textbox with the text like
c:\bob.txt and in another textbox I want it to show
c:\bob.doc
But I am getting the file name with a common dialog so I can't type that in for the text.. I hope this makes sense, I need to simply change the extention of the whatever is listed in textbox1.
Ed Farias
-
Aug 29th, 2000, 04:48 PM
#2
_______
<?>
Dim strString As String, intLen As Integer
strString = Text1.Text
intLen = Len(strString)
strString = Left(strString, (intLen - 3))
strString = strString & "doc"
Text1.Text = strString
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 29th, 2000, 04:51 PM
#3
you mean like this??
Code:
Text1 = Left(Text1, Len(Text1) - 4)) & ".doc"
that will change the extenstion to .doc, but if it doesnt have an extension, it will add a doc extension(it will also take away four letters of the name).
[Edited by denniswrenn on 08-29-2000 at 05:55 PM]
-
Aug 29th, 2000, 05:09 PM
#4
_______
<?>
Code:
Option Explicit
'guess my first answer was off the cuff and too hasty
'if you want to error code it it would work like this
Private Sub Command1_Click()
Dim SearchString, SearchChar, MyPos
SearchString = Text1.Text
SearchChar = "."
MyPos = InStr(1, SearchString, SearchChar, 1)
'if found MyPos will be > 0
If MyPos > 0 Then
Text1.Text = Left(Text1, MyPos) & "doc"
Else
'your error code goes here
MsgBox "There seems to be no extension"
Exit Sub
End If
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|