Results 1 to 2 of 2

Thread: simple array problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    7

    Unhappy

    What exactly can an array store, can arrays store text/images or just text. If it can store both how would you dimension it eg. dim blah(1 to 5) as ???

    Here is the code that im having trouble with. I am making a multi-use clipboard and i want to store either an image/text from the clipboard and then paste it back... the code works now but what i had to do was create several imageboxes to store the images in because when i try to store image data in an array and try and retrieve it it says there is no data. Is there any way like a control or variable that can store both images and text?

    any information or solutions would be a great help

    thanks

    vishal

    THE CODE:

    Dim Storage(1 To 5) As Variant
    Dim SelectedOpt As Integer



    Public Function StoreIt(i As Integer) 'Storage function

    If Clipboard.GetFormat(vbCFText) = True Then
    'If the clipboard contains text store it in an array
    Storage(i) = Clipboard.GetText
    txtStorage(i).Text = Mid$(Clipboard.GetText, 1, 20) & "..."
    txtStorage(i).Enabled = False

    ElseIf Clipboard.GetFormat(vbCFBitmap) = True Then
    'If the clipboard contains an image store it in an imagebox
    imgStorage(i).Picture = Clipboard.GetData(vbCFBitmap)
    txtStorage(i) = " (picture)"
    txtStorage(i).Enabled = False
    Else
    'If its not text or an image then the format is invalid
    MsgBox "Invalid format."
    End If

    End Function


    Public Function CopyIt(n As Integer) 'Copy to clipboard function
    If txtStorage(n).Text = " (picture)" Then
    'If it is a picture copy it from the image storage
    Clipboard.SetData imgStorage(n).Picture, vbCFBitmap
    Else
    'If it is text then copy it from the text storage
    Clipboard.SetText Storage(n), vbCFText
    End If
    End Function

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'this might be a walk around...would save the overhead of multiple
    'image boxes
    'hard coded C:\my documents for example but I would use
    'appPath & "myBmp" & i & ".bmp"
    
    
    ElseIf Clipboard.GetFormat(vbCFBitmap) = True Then
    
    'If the clipboard contains an image store it in a file
    SavePicture Clipboard.GetData(vbCFBitmap), "C:\My Documents\My2Bmp" & i & ".bmp"
    'load the array
    txtStorage(i) = "C:\My Documents\My2Bmp" & i & ".bmp"
    txtStorage(i).Enabled = False
    Else
    'If its not text or an image then the format is invalid
    MsgBox "Invalid format."
    End If
    
    'you could later load the imaage box
      'Set Image1.Picture = LoadPicture(txtStorage(0)  'or whatever element
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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