Home > Software engineering >  Turn to rewrite a method
Turn to rewrite a method

Time:09-26

The following is a need to rewrite the method, if imgPath travels is picture url, change the method how to write?

 Public Function RTS_UpdateImageData_m (ByVal imgPath As String) As Long 
Dim the updatedata () As Byte
Dim writelen As Long
'Dim imgPath As String
'imgPath="c: \ \ 01. JPG"
Dim the Mst As ADODB. Stream
'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Set the Mst=New ADODB. Stream
The Mst. Type=adTypeBinary 'binary Type
The Mst. Open
The Mst. LoadFromFile imgPath 'loading pictures, pictures imgPath as path
'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The updatedata=https://bbs.csdn.net/topics/Mst.Read 'read the file flow
Writelen=UBound (the updatedata) - LBound (the updatedata) + 1 'for the length of the array
RTS_UpdateImageData_m=RTS_UpdateImageData (VarPtr (the updatedata (0)), writelen)
End the Function

CodePudding user response:

CodePudding user response:

A little change is ok? -- -- -- -- -- - I don't know if we can directly use the Internet address, not so used,
Join cannot directly use the Internet address:

Add a judgment of imgPath, if is the network address is downloaded using urldownloadtofile function to the local, and then reference the local address,

CodePudding user response:

refer to the second floor Topc008 response:
slightly change should be ok? -- -- -- -- -- - I don't know if we can directly use the Internet address, not so used,
Join cannot directly use the Internet address:
Add a judgment of imgPath, if is the network address is downloaded using urldownloadtofile function to the local, and then reference the local address,


Can not directly use the Internet address, judge does not need to be increased, imgPath affirmation is the network address, just want to turn into a can be used directly,

CodePudding user response:

Search urldownloadtofile function

CodePudding user response:

To download, save as a local file, then save to the database,

CodePudding user response:

Let's download

CodePudding user response:

Use the picture to load network images, and then save the picture in the picture to the local can, in the read write database

CodePudding user response:

CodePudding user response:

This not line, if the stored image path, in the data table must add a field, such as path, text type, the size of 100 bytes is sufficient, then put the path of images stored in the field, if it is a storage of binary images, path field is empty,
In the program to determine whether a path is empty, if empty, not empty or use statement, call different image loading method:
Dim cn As New ADODB library. The Connection, the RS As New ADODB. You
'I don't know your connection to the database and data table joins, this part of the code slightly
If the RS! Path="" Then
'you read binary data and display the image of the code
ElseIf RS! Path & lt;> "" Then
Dim LUJ As String
LUJ=RS! Path
Image1. Picture=LoadPicture (LUJ)
Controls to display images' Image1 is name
End the If

  • Related