Results 1 to 7 of 7

Thread: Changing "C:\Filename" to "\\CompName\C$\Filename"

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Posts
    93
    I have an access database that has filenames of pictures stored in it. The filenames are written as "C:\filename". I need to write a program that accesses these filenames across the network, but I cannot access "C:\Filename". I need to access "\\ComputerName\C$\filename".

    How can I place the text into a varible and then delete the first two characters? I know how to append what I need to on to it.

    Or if there is a better way to do it how can I do it.


    Thanks
    Brandon

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Code:
    Private Sub Command1_Click()
        Dim strTest As String
        strTest = "c:\filename"
        strTest = "\\ComputerName\C$" & Mid$(strTest, 3, Len(strTest))
        MsgBox strTest
    End Sub
    [Edited by jbart on 11-10-2000 at 12:07 PM]

  3. #3
    Member
    Join Date
    Sep 2000
    Location
    Midwest
    Posts
    35

    change variable name

    I think that the second "strtest" should be name "strtest2", is this correct JBart?

  4. #4
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    It seems to work correctly the way it is coded. The concept is similar to x = x + 1. You are just updating the variable with the result of an equation containing the variable. The result displayed in the message box is:

    \\ComputerName\C$\filename

    I suppose you could create a second variable to hold the result, but the following shows the same output.

    Code:
    Private Sub Command1_Click()
        Dim strTest As String
        strTest = "c:\filename"
        MsgBox "\\ComputerName\C$" & Mid$(strTest, 3, Len(strTest))
    End Sub
    It's just an example to show that you can use the Mid$ function to drop off the first 2 positions of the filename contained in strTest.

    [Edited by jbart on 11-10-2000 at 12:49 PM]

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Posts
    93
    Thanks Guys. I have the program working great. Thanks to you.


    Brandon

  6. #6
    Member
    Join Date
    May 2000
    Location
    Canada
    Posts
    52
    Dim X as string
    x = replace(rsYourRecordset!YourPicture, "C:\Filename","\\ComputerName\C$\filename")



  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Originally posted by d.paulson
    Dim X as string
    x = replace(rsYourRecordset!YourPicture, "C:\Filename","\\ComputerName\C$\filename")
    His program already works.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width