-->>Hello, I hope I can get help on this its like this...
-->>I have an application that allows a User to brows files in a Computer...
-->>On My point of interest Zipped files,that's My filtering Criteria...
-->>When the File wiht .zip is found it is displayed on the Textbox very fine...
-->>But what I don't like is the way it is displayed with its extention of .zip...
-->>For Example if its name is 'Bile',it shows up like this 'Bile.zip' which I dont see good...
-->>So please what should I do to remove the Last 4 characters '.zip' and remain with only 'Bile'...
-->>Regards.

try this Text1.Text = Split(Filename, ".")(0) This splits the string using the "." as a delimeter and returns the first element.

I agree with tinstaafl. Problem is that when there are more than 1 dot in a value, it might return the incorrect information. I would rather use something like this -

Public Sub SplitIt(strText As String, txtResult As TextBox)
    Dim SplitPoint As Integer
    Dim strPart1 As String
    Dim strPart2 As String

    SplitPoint = InStr(strText, ".")
    strPart1 = Left(strText, SplitPoint - 1)
    strPart2 = Right(strText, Len(strText) - SplitPoint)
    strText = "Part1 = " & strPart1 & " Part2 = " & strPart2

    txtResult.Text = strText
End Sub

Now you can call it in any form -

Call SplitIt(Text1.Text, Text2) ''Text1 is the part to split, Text2 is the box where you will display the value...

@Andre, did you by chance mean to use InstrRev in line 6 of your code?

Here's my entry for this mundane function.

Function RemoveExt(fname As String, Optional extToRemove As String = "") As String
    ' if extToRemove = "" then all extensions removed
    Dim pt_pos As Integer
    pt_pos = InStrRev(fname, ".")
    If pt_pos <> 0 Then
        If extToRemove = "" Then
            'Remove all extensions
            RemoveExt = Left(fname, pt_pos - 1)
        Else
            extpart = Right(fname, (Len(fname) - pt_pos) + 1)
            If LCase(extpart) = LCase(extToRemove) Then
                RemoveExt = Left(fname, pt_pos - 1)
            Else
                RemoveExt = fname
            End If
        End If
    Else
        RemoveExt = fname
    End If
End Function
commented: Indded, because of more functionality :) +13

You could try:

Dim Temp() as String = Split(Filename, ".")
If Temp.Length > 1 Then
    For I = 0 to Temp.Length-2
        If I = 0 Then
            Text.Box1.Text = Temp(I)
        Else
            Text.Box1.Text = TextBox1.Text + "." + Temp(I)
        End If
    Next
End If

This will return any filename without the extension, even if it is without one already, or if there are multiple periods, it will return everything except after the last period.

@TNTin, Both will work fine as to where InstrRev will give you more options if you want to start from a certain letter etc. See here :)

Seems we have quite a few options for our poster friend. :)

It's amazing how much we've forgetten when we're reverting to this ancient technology lol.
Try this:

    If InStrRev(Filename, ".") > 0 Then
        Text1.Text = Mid(Filename, 1, (Len(Filename) - (Len(Filename) - InStrRev(Filename, ".") + 1)))
    Else
        Text1.Text = Filename
    End If

This does the exact same thing, without the for loop

-->>BIG UP TO YOU GUYZ...
-->>All the method Worked out fine...
-->>I REALY APPRICIATE YOU GUYZ...
-->>Thanks a lot.

Only a pleasure. Happy coding...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.