Hola mi duda es la siguiente:
Tengo un check1, un label1, y agregue CommonDialog1.
Cuando clickeo en el check1 se me abre el cuadro para buscar archivos, l configure solo para *.mp3 y *.wav. Y cuando busco el archivo lo clickeo y pone me guarda toda la direccion en el label1.
Aqui el codigo:
Private Sub Check1_Click()
CommonDialog1.ShowOpen
Label1.Caption = CommonDialog1.FileName
End Sub
Bueno ahora tengo un boton1 q lo q quiero q haga es q al clickearlo me ejecute ese mp3 o wav.
Codigo del boton:
Private Sub Command1_Click()
mciExcecute ("Play " & Label1.Caption)
End Sub
El problema surge q si agrego un mp3 el cual contenga espacios en blanco me tira error.
Por ejemplo: C:\Aerosmith crazy.mp3 ESTO NO ANDARIA pero si seria C:\AerosmithCrazy.mp3 o C:\Aerosmith-Crazy.mp3 ESTO SI ANDARIA
hola la solucion y esta provada que funciona es utilizar el api GetShortPathName
te paso un ejemplo despues vos lo adaptas
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(strFileName As String) As String
Dim lngRes As Long, strPath As String
'Create a buffer
strPath = String$(165, 0)
'retrieve the short pathname
lngRes = GetShortPathName(strFileName, strPath, 164)
'remove all unnecessary chr$(0)'s
GetShortPath = Left$(strPath, lngRes)
End Function
Private Sub Form_Load()
MsgBox GetShortPath("C:\Archivos de programa")
End Sub
Muchas gracias, lo adapté a mi codigo quedo perfecto :D