Results 1 to 5 of 5

Thread: One simple l'ine of code stoppin prog to work!! Help!

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    Leeds England
    Posts
    54

    Arrow One simple l'ine of code stoppin prog to work!! Help!

    Adding variable names!
    i have this line of code in a vb app:
    Picturebox1.Picture = LoadPicture("C:\Matt\Cards\" & RandomCardName & ".bmp")

    i want it to load a picturefrom the file
    C:\Matt\Cards\Filename.bmp

    seen as this file will be randomly choen by an array and stored inthe variabe RandomCardName
    now the code above looks for file
    C:\Matt\Cards\.bmp
    can anyone solve it?? heeeeeelp!


  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    if RandomCardName is an integer then u need to write:

    CStr(RandomCardName)

    so it would look like:

    Picturebox1.Picture = LoadPicture("C:\Matt\Cards\" & CStr(RandomCardName) & ".bmp")

    Try that

    or try

    Picturebox1.Picture = LoadPicture("C:\Matt\Cards\" + CStr(RandomCardName) + ".bmp")

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    Leeds England
    Posts
    54
    so far i have tried the idea in the first pot, but when i run the code, it says object required, and points to picturebox1.picture
    now i have a picture so what is the prob??

  4. #4
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    try "Set PictureBox1.Picture = ....."
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    Leeds England
    Posts
    54

    Done it!!!

    It was own to an error on my part! i was trying to open a picture in Picturebox1.picture yet the comp doesnt call them that! They are set at a default of picture1. cheers for the help though!

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