Click to See Complete Forum and Search --> : Option Strict On
PT Exorcist
Aug 2nd, 2002, 10:56 AM
i put option strict on to check it out but i having some problems like this one:
Files = FSO.GetFiles(ListView2.Items.Item(y).SubItems(1).Text & ListView2.Items.Item(y).SubItems(0).Text, TextBox2.Text)
he is saying this:
C:\Documents and Settings\JBRANCO\My Documents\Visual Studio Projects\thumber\Form1.vb(439): Option Strict On disallows implicit conversions from 'System.Array' to '1-dimensional array of String'.
what do i do to convert it?
also is option strict a good thing?
Edneeis
Aug 2nd, 2002, 11:22 AM
Not sure but try this:
Files = CType(FSO.GetFiles(ListView2.Items.Item(y).SubItems(1).Text & ListView2.Items.Item(y).SubItems(0).Text, TextBox2.Text),String)
PT Exorcist
Aug 2nd, 2002, 11:46 AM
i am still getting error with that
Edneeis
Aug 2nd, 2002, 12:13 PM
What is Files declared as?
dim Files as array
DevGrp
Aug 2nd, 2002, 12:20 PM
The problem might be with Files. What is it declared as?
Also FSO.GetFiles is returning an array.
Post more of the code.
BTW leave on option strict. It forces you to explictly conversion and so forth.
PT Exorcist
Aug 2nd, 2002, 01:04 PM
hmmmmmmmmm k
ljlevend
Aug 5th, 2002, 08:18 AM
Sorry, the computer I'm on doesn't have VS.NET so I can't test this, but I think this is what is going on...
The " 'System.Array' to '1-dimensional array of String' " means that you are trying to do the following:
Dim array as System.Array
Dim stringArray() as String
'The following line will cause an Exception
array = stringArray
If FSO.GetFiles returns an array of Strings, then Files must be declaired by using the following:
Dim Files() as String
If needed, you can use the following technique to convert an array of one type to an array of another type:
Dim array as System.Array
Dim stringArray() as String
'ADD CODE TO FILL array HERE...
'The Array that you copy to must be able to hold the data
Redim stringArray(array.GetUpperBound(0))
'Use Array.Copy to convert array to stringArray
System.Array.Copy(array, stringArray, stringArray.Length)
Hope this helps.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.