Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Couple Questions

Status
Not open for further replies.

Ablecken

Programmer
Jun 5, 2001
130
US
First:
If I had a slider bar how would i make it control the system volume? Like if i changed it on my form how could i make it change the volume for the computer at the same time?

Second:
If i had a common dialog box and i got the file name of a file. it gives the whole path right? how could i find out the extension of the file selected?

Thanx a lot guys
 
Feed the FileName into the following function and in return you will get the FileExtension

Private Function ExtractExtension(strFileName As String) As String

Select Case Len(strFileName)
Case Is = 0
ExtractExtension = vbNullString
Case Is > 0
Dim astrFileName() As String
astrFileName = Split(strFileName, "\")

Dim astrFileExtension() As String
astrFileExtension = Split(astrFileName(UBound(astrFileName)), ".")

Select Case UBound(astrFileExtension)
Case Is = 0
ExtractExtension = vbNullString
Case Is <> 0
ExtractExtension = astrFileExtension(UBound(astrFileExtension))
End Select

End Select

End Function


Uppon return, check for a possible NullString, indicating either no FileName provided to the funcion or the FileName string contained no extension.
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top