Results 1 to 7 of 7

Thread: Option Strict On

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Option Strict On

    i put option strict on to check it out but i having some problems like this one:

    VB Code:
    1. 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?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Not sure but try this:
    VB Code:
    1. Files = CType(FSO.GetFiles(ListView2.Items.Item(y).SubItems(1).Text & ListView2.Items.Item(y).SubItems(0).Text, TextBox2.Text),String)

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i am still getting error with that

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What is Files declared as?

    dim Files as array

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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.

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmmmmmmmmm k

  7. #7
    Member
    Join Date
    Mar 2002
    Posts
    40
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width