[Gambas-user] Array 2 String or different approach on what im trying to do.
ron
ronstk at ...239...
Wed Jan 9 06:25:01 CET 2008
On Tuesday 08 January 2008 19:43, lozza1978 wrote:
>
> Hi All.
>
> Im after a little help again (Sorry for lack of knowledge guys)
>
> I have a textbox and a browse button, you click browse, select a file and
> the file path, including filename gets added inside the textbox.
>
> what im after is the directory of the file selected, so this is what I have
>
>
> DIM Elt AS String[]
> DIM Sb AS String
> DIM Sdir AS String
> DIM sstri AS String[]
>
> Dialog.Title = "Select A Movie File to convert 2 DVD:"
> IF Dialog.OpenFile() THEN RETURN
> Textbox1.Text = Dialog.Path
>
>
> Elt = Split(Textbox1.Text, "/") <--Split the path
>
> Sdir = Elt.Length - 1 <--here Im finding out how many elements in the array
> Elt.Remove(Elt.Length - 1) <-- here removing the filename, so that I have
> the directory where the file is located
>
>
> FOR EACH Sb IN Elt
>
> PRINT sb; "/";
>
> NEXT
> PRINT
> END
>
>
> the code above works and the foreach prints the correct directory path, But
> i some how need to get the output of the foreach into a string so I can call
> the directory path using a string/variable
>
> im just confusing myself now, hope someone can understand what im trying to
> do and help me, thanks again for reading.
>
>
>
In you way:
DIM Elt AS String[]
Elt = Split(Textbox1.Text, "/") <--Split the path
' http://gambasdoc.org/help/comp/gb/string[]/pop
Elt.Pop() <-- here removing the filename
' http://gambasdoc.org/help/comp/gb/string[]/join
thedir= Elt.join('/') <-- the path
But the most simple one:
thedir=File.Dir(Textbox1.Text)
Ron
More information about the User
mailing list