Help: Upload dll with multiple Select list


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Help: Upload dll with multiple Select list

  1. #1
    Join Date
    Jan 2007
    Posts
    10

    Help: Upload dll with multiple Select list

    This site is the best one for vb newbie like me!

    I am writing one upload dll simlar functions to aspSmartUpload component, (of course, I get a lot of code and help from this site!).

    I made the upload and download functions working, but then I found I have problem to display form variables for miltiple select list, since it is same name with mulitple values.

    I use form collection to collect all the form variables, when I parse the raw data to get name and value. I look for some advice/guide on this.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2007
    Posts
    10

    Please help!

    The following is what I try to do.

    'Get the FormFieldName
    strFormFieldName = MidB(varHTTPHeader, lngFormFieldNameStart + Len(StrConv("; name=" & Chr(34), vbUnicode)), (lngFormFieldNameEnd - Len(StrConv(Chr(34), vbUnicode))) - (lngFormFieldNameStart + Len(StrConv("; name=" & Chr(34), vbUnicode))))

    'Filter formfieldvalue
    strFormFieldValue = MidB(varHTTPHeader, lngFormFieldValueStart, lngFormFieldValueEnd - lngFormFieldValueStart)

    If IsEmpty(c_FormItems.Item(strFormFieldName)) Then
    c_FormItems.Add strFormFieldValue, strFormFieldName
    Else
    Dim cValue As String
    cValue = c_FormItems.Item(strFormFieldName)
    'remove the item, can I modify?
    c_FormItems.Remove (strFormFieldName)
    cValue = cValue & "," & strFormFieldValue
    c_FormItems.Add cValue, strFormFieldName
    End If

    so if I have "option1" and "option2" both selected, I can have value as "option1,option2" returned just like request.form("select").

    Update: I always get the error saying: Invalid procedure or argument.

    and I thought I could use c_FormItems.Add (strFormFieldValue,strFormFieldName), but it gave me compile error, I have to change to c_FormItems.Add strFormFieldValue,strFormFieldName, it let me compile, but give the above error.

    Please help!
    Last edited by vbdll; 01-12-2007 at 03:31 PM. Reason: Update for help

  3. #3
    Join Date
    Jan 2007
    Posts
    10

    Please help!

    How do I check if item exists in collection and then modify the item?

    I look all over in MSDN, and alwway get error about Invalid procedure call or argument.

  4. #4
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    well in vb u can't put brackets if u havent a return to a variable ..
    I mean this is ok : " a=function(arg1,arg2) " which will execute the function then put the return value in a, but this is not accepted : function(arg1,arg2) however if the function haven't a return value ,, u must not put bracktes here ..
    the nearest example is the MsgBox() function .
    about your error I think you have problem with the function call , check this :
    -what is c_FormItems?
    -does it have a member function ".add" ?
    -does it take two parameters only ?
    -u pass it a valid argument ? I mean if the arg1 is form , u must pass a form and so on ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  5. #5
    Join Date
    Jan 2007
    Posts
    10
    Thanks for the reply.

    c_FormItems is a collection, the Add is the default method, which supposed to be .add (value, key), but I get complie error, so I use .add value, key.

    Dim c_FormItems As Collection

    OnStartPage()
    Set c_FormItems = New Collection

    When I do strTry = c_FormItems(strFormFieldName), it complian about this retieve.

    Dim strTry As String
    'On Error Resume Next
    strTry = c_FormItems(strFormFieldName)

    Here is the code:
    PHP Code:
     (sorryjust use the php tagit's vb code of course)
    If the field is a file, add into fileitems collection
    Else

                '
    Determine where filedata begins
                lngFormFieldValueStart 
    InStrB(lngFormFieldNameEndvarHTTPHeadervbCrLf vbCrLf) + Len(StrConv(vbCrLf vbCrLfvbUnicode))
                
    'Determine where filedata ends
                lngFormFieldValueEnd = InStrB(lngFormFieldValueStart, varHTTPHeader, vbCrLf & varDelimeter)
                
                '
    Filter formfieldvalue
                strFormFieldValue 
    MidB(varHTTPHeaderlngFormFieldValueStartlngFormFieldValueEnd lngFormFieldValueStart)

                
    'we will search for next field from here...
                lngFormFieldNameStart = lngFormFieldValueEnd
                
                '
    save the fields value
                strDebug 
    strFormFieldValue strFormFieldName
                Dim strTry 
    As String
                
    'On Error Resume Next
                '
    strTry c_FormItems(strFormFieldName)
                
    strTry strFormFieldName
                
    If Len(strTry) > 0 Then
                    strDebug 
    "multiple"
                
    Else
                    
    strDebug "single"
                    'c_FormItems.Add strFormFieldValue, strFormFieldName
                End If
                c_FormItems.Add strFormFieldValue, strFormFieldName
    End If 
    If I comment out the 'strTry = c_FormItems(strFormFieldName), I dont receive the Invalid procedure call or argument.


    Thanks again for your help.
    Last edited by vbdll; 01-12-2007 at 04:32 PM.

  6. #6
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819

    Arrow

    In this collection u must put an integer that points to the index of the selected item ,
    I guess that "strFormFieldName" is a string not a long .. so u want to assigne what ? u must specify the index in this collection which contains this string variable and put it into those brackets .
    Last edited by Amahdy; 01-12-2007 at 05:02 PM.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  7. #7
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    *ps u can use [ code ] tag .. it hasn't a colourful interface but it adjust spaces .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  8. #8
    Join Date
    Jan 2007
    Posts
    10
    Quote Originally Posted by Amahdy
    In this collection u must put an integer that points to the index of the selected item ,
    I guess that "strFormFieldName" is a string not a long .. so u want to assigne what ? u must specify the index of this collection which contains this string variable and but it into those brackets .
    I thought you dont have to use index, instead use key.

    http://msdn2.microsoft.com/en-us/lib...e5(VS.80).aspx

    So how should I retrieve the value and modify, basiclly I want to:

    I have form name and value parsed from raw data, let says mulitple list named cblist with 2 values (option1, and option2).

    So I get the first set, cblist->option1, and I add to collection key is cblist, value is option1, then next parse I got cblist->option2, I want to modify my cblist's value to "option1,option2".

    That's what I come from, check if the item (cblist) has a value already, if it has, modify it.

    Hope I made it clear what I mean.

  9. #9
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    No this is different , the index of the item is different from the "Optional" key of the item .. u have used this : object(string) which is must be object(index_of_type_long)
    in the other side in the add method u can do that :
    object.add(item, key_string) OR object.add(item)
    well returning back to your original code , which gives u invalid call , maybe because the key is not "unique" ? do u use it for different items or in a loop for example ?
    I'm talking about this :"strFormFieldName" maybe it's empty ? or maybe the item itself is not defined ?
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  10. #10
    Join Date
    Jan 2007
    Posts
    10
    Quote Originally Posted by Amahdy
    well returning back to your original code , which gives u invalid call , maybe because the key is not "unique" ? do u use it for different items or in a loop for example ?
    I'm talking about this :"strFormFieldName" maybe it's empty ? or maybe the item itself is not defined ?
    You are great! I do have some loop which gave me some grief, I dare not to post all code (kind of long and messy), but I will look more carefully to see if I could find the problem.

  11. #11
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    U r mostly welcome Mr. ActivX [I liked your nickname ]
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  12. #12
    Join Date
    Jan 2007
    Posts
    10
    I still could not find the problem, I use index or even hardcode,like this:

    Dim x As Variant
    x = c_FormItems.Item("cblist1")
    or
    x = c_FormItems.Item(1)

    still give me the error. I found someone's post, It works if for a collection of strings, but I can not find what I did wrong!

    http://www.experts-exchange.com/Prog..._21736095.html


    Code:
    Public Function existInColl(tmpCollection As Collection, key As String) As Boolean
        Dim x As Variant
        On Error Resume Next
        x = tmpCollection.item(key)
        If IsEmpty(x) Or x = "" Then
            existInColl = False
        Else
            existInColl = True
        End If
        On Error GoTo 0
    End Function
    my head is spinning, sigh...

  13. #13
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    I think this guy is wrong it must be :
    x = tmpCollection.item(INDEX)

    your error here:
    x = c_FormItems.Item(1)
    maybe you haven't the item 1 ? u must first add the item 1 to be able to get it by your method ..
    remember : a collection is 1 based but arrays in collection are zero based :
    c_FormItems(One_Based)
    c_FormItems.xyz(zero_bazed)
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  14. #14
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    ###I'm sorry I gived u wrong info, all sub arrays from collection are one based too ;
    try this :

    Code:
    Dim a As Collection
    Set a = New Collection
    
    a.Add ("string")
    MsgBox a.Item(1)
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  15. #15
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    ###I'm sorry again but I gived u wrong info again, in collections u can call items by their key ...
    try this :

    Code:
    Dim a As Collection
    Set a = New Collection
    
    a.Add "string", "alpha"
    MsgBox a.Item("alpha")
    I had a confusion with something else but now it's ok isa .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

Similar Threads

  1. Replies: 0
    Last Post: 10-18-2006, 11:19 PM
  2. Replies: 0
    Last Post: 09-19-2006, 06:08 PM
  3. ListBot Going Out of Business
    By Larry Rebich in forum vb.announcements
    Replies: 1
    Last Post: 06-28-2001, 01:22 PM
  4. Stored Procedure (Want looping in Cursor)
    By malikmehmood in forum Database
    Replies: 0
    Last Post: 11-20-2000, 05:12 AM
  5. Adding Items to a SELECT list
    By Brent in forum Web
    Replies: 1
    Last Post: 09-17-2000, 08:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center