|
-
Apr 22nd, 2005, 08:15 PM
#1
Thread Starter
Fanatic Member
How to set picture in ImageBox
i have picture in RS(2) how can i set this picture into Image1 ...??
-
Apr 22nd, 2005, 08:42 PM
#2
Re: How to set picture in ImageBox
-
Apr 22nd, 2005, 08:45 PM
#3
Member
Re: How to set picture in ImageBox
some what confused. but to set an image in a picturebox. in the properties u go to picture option and click on it then click on the ... to the right then it brings up the browse thing to find the picture. was that wut u were asking?
-
Apr 22nd, 2005, 08:50 PM
#4
Thread Starter
Fanatic Member
Re: How to set picture in ImageBox
 Originally Posted by dglienna
what is RS(2) ?
it is RECORDSET.... and 2 is index of COLUMN....
I m using IMAGE CONTROL
-
Apr 22nd, 2005, 08:51 PM
#5
Addicted Member
Re: How to set picture in ImageBox
If the object in RS(2) is a StdPicture, then use:
Set Image1 = RS(2)
-
Apr 22nd, 2005, 09:03 PM
#6
Thread Starter
Fanatic Member
Re: How to set picture in ImageBox
When i was trying
Set Image1.Datasource =rs <=== Type MisMatch Error
Set Image1.Datasource =rs <=== Type MisMatch Error
And now
Set Image1 =rs(2) <=== Invalid Picture Error
..?
-
Apr 22nd, 2005, 09:09 PM
#7
Addicted Member
Re: How to set picture in ImageBox
What exactly is in RS(2)? Is it a string path, or a picture object, or something else?
-
Apr 22nd, 2005, 09:11 PM
#8
Re: How to set picture in ImageBox
I will give give logic I use but don't ask me to modify it for you - I'm sure you will figure it out how it works :
VB Code:
Option Explicit
Public Const MAX_PATH = 260
Public Const BLOCK_SIZE = 10000
Private Declare Function GetTempFileName Lib "kernel32" _
Alias "GetTempFileNameA" _
(ByVal lpszPath As String, ByVal lpPrefixString As String, _
ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Sub ExtractImage(rstTemp As ADODB.Recordset, sTitle As String, pctTemp As PictureBox)
'============================================================================================
Dim bytes() As Byte
Dim file_name As String
Dim file_num As Integer
Dim file_length As Long
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long
Dim hgt As Single
On Error GoTo ErrHandler
'me.imgPhoto.Visible = False
Screen.MousePointer = vbHourglass
DoEvents
rstTemp.Find "Title='" & sTitle & "'"
' Get a temporary file name.
file_name = TemporaryFileName()
' Open the file.
file_num = FreeFile
Open file_name For Binary As #file_num
' Copy the data into the file.
file_length = rstTemp("fImageSize")
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE
'get all chunks and write then to a temp file
For block_num = 1 To num_blocks
bytes() = rstTemp("fImage").GetChunk(BLOCK_SIZE)
Put #file_num, , bytes()
Next block_num
If left_over > 0 Then
bytes() = rstTemp("fImage").GetChunk(left_over)
Put #file_num, , bytes()
End If
Close #file_num
'load image
pctTemp.Picture = LoadPicture(file_name)
Screen.MousePointer = vbDefault
Exit Sub
ErrHandler:
'-----------
Debug.Print Err.Description
Err.Clear
Resume Next
End Sub
Public Function TemporaryFileName() As String
'==============================================
Dim temp_path As String
Dim temp_file As String
Dim length As Long
' Get the temporary file path.
temp_path = Space$(MAX_PATH)
length = GetTempPath(MAX_PATH, temp_path)
temp_path = Left$(temp_path, length)
' Get the file name.
temp_file = Space$(MAX_PATH)
GetTempFileName temp_path, "per", 0, temp_file
TemporaryFileName = Left$(temp_file, InStr(temp_file, Chr$(0)) - 1)
End Function
-
Apr 22nd, 2005, 09:13 PM
#9
Thread Starter
Fanatic Member
Re: How to set picture in ImageBox
rs(2) contains PICTURE OBJECT
i have table1
fieldname =picture
this field data type = OLE Object
-
Apr 23rd, 2005, 07:49 AM
#10
Thread Starter
Fanatic Member
Re: How to set picture in ImageBox
 Originally Posted by vbPoet
rs(2) contains PICTURE OBJECT
i have table1
fieldname =picture
this field data type = OLE Object
RhinO i appreciates your effort ...!
But i think there should be some simple way of it ....
there is OLE OBJECT in rs(2)
and i want to get that picture displayed in IMAGE CONTROL ...
-
Apr 23rd, 2005, 07:53 AM
#11
Re: How to set picture in ImageBox
vbPoet, there is no "simple" way to do it. What RhinoBull posted is good and is what you need. You should take a look at it again.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 23rd, 2005, 07:58 AM
#12
Thread Starter
Fanatic Member
Re: How to set picture in ImageBox
-
Apr 23rd, 2005, 08:03 AM
#13
Re: How to set picture in ImageBox
Well, there may be using a data "type" control but I never use then since they are eveil 
If you were using ADO then I do believe its easier with the ADODC data control to bind the datasource of the image control to it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|