Link to home
Start Free TrialLog in
Avatar of eladr
eladr

asked on

3 easy one for the beginner

1.I want to make special icon for my application.
I noticed that the application can accepts only "ico" extension.
how can i make ico image?can i convert gif,jpg,bmp to ico?

2.I opened standart exe project and i add data enivroment.
i make a connection and command.
then,i added data grid control and i set the data source and the data
member to the data enivroment to retrieve the rows to the grid.
everything works good.
now i changed the sql query in the command to " select * from tblName where id=?" (i want to assign a parameter)
how can i assign parameter to this command so i will see the selected row in the grid?
i tried :
'3 is the id
conn_name.dataenviroment_name.rscommand = 3
but i got error...

3.i have 4 rows in some database which one of it's fields is : imageName.
like this
pic1.gif
pic2.jpg
mypic.gif
family_pic.jpg
i want to loop over records like this and to show thumbhill's of the pictures
in my standart exe form
...
dim image_name as string
do while not rs.eof
     image_name = rs!imageName
     rs.moveNext
loop
...

(
in asp i would do:
<img src='<%=image_name%>' border=0>
)
how can i do that in my exe form?
thanks in advance
elad
Avatar of JanusFury
JanusFury

1.
Check out Microangelo by Impact Software...
www.impactsoft.com
It makes icons and cursors and has a built-in feature for loading GIF files and BMP files.

2.
I think you might want to try embedding the number in the SQL query, like this:

" select * from tblName where id=3"

I don't know, I don't do much database work.

3.
That requires a little effort, you'll either have to use an array of image controls, and load images into them, or paint the images directly onto your form. For the image controls it'd work like this:

dim image_name as string, current_image as long
do while not rs.eof
    image_name = rs!imageName
    set image_controls(current_image).Picture = LoadPicture(image_name)
    rs.moveNext
    current_image = current_image + 1
loop

Of course you'd have to position the image controls as well, but that'd be more application-specific.

Hope this helps...
Janus

JanusFury is correct on all three, but in #2, I suspect you want to replace it with a variable, then fill the variable based on some criteria elsewhere in the program.  Alternately, you can use an object property, like the value of a textbox:

Ex1:
..."Select * from tblName where id=" & variablename

Ex2:
..."Select * from tblName where id=" & Text1.Text

For example 2, make sure you include error-trapping since the user could have put a non-numeric value into the textbox.
Avatar of eladr

ASKER

about 1 - thanx
about 2 - you didnt answered on my que.
i want to add my parameter through the dataEnviroment and to do this exactly as described
about 3 - not working
i got type mismatch.
this is my code:
Private Sub Form_Load()
   image_name = "c:\elad\eden.gif"
   current_image = 0
   For i = 0 To 2
    Set Image1(current_image).Picture = LoadPicture(image_name)
    current_image = current_image + 1
   Next
End Sub
thanx
Try removing the "Set" to clear up the type mismatch.  It's one of those few places where you do NOT use it!

As for your second question, I answered they way I interpreted your question.  Maybe you can restate it?
? I've never had a type mismatch problem with picture objects O_O I'll have to try his code and see what happens.
I've never been able to set objects without using set, either ... ?
>I've never been able to set objects without using set, either ... ?

That's true, but the picture property is not an object so it shouldn't have a Set.  LoadPicture returns a long that corresponds to a picture handle, so you simply use an assignment to the picture property, which expects a long.
eladr:

YOU have over TWENTY open questions dating back to September of last year!!! PLEASE tend to those questions WITH A COMMENT, grade or deletion.. BEFORE proceeding here!!!

YOU come here free of charge.. ask we experts for our help.. we contribute our personal time and our knowledge to YOU FREE of charge.. don't you feel that the least YOU can do is keep YOUR questions up to date with a comment of your current status stating what is lacking in the Expert response there?!?!?!?!?!

PLEASE.. BEFORE bleeding all the Experts here in this question.. take a moment and bring the Experts in YOUR TWENTY odd OPEN Questions up to date with YOUR current status !!!

Try to respond to wsh2's comments.
Avatar of eladr

ASKER

thanks all - i will try solution and let you know.
and for wsh2 comment:
it amazed me - i cant remember of such many quetions i left.
im the most polite and honest user of EE(i also have more than 5000 pts helping other people)
i always "close" my que and sometimes i give more pts than i offer in my first comment.
But i will check - promise.
just tell me which subject?VB?asp?
elad
Avatar of eladr

ASKER

i omited the set and still "type mismatch"
this is my code:

Private Sub Form_Load()
  image_name = "c:\elad\eden.gif"
  current_image = 0
  For i = 0 To 2
   Set Image1(current_image).Picture = LoadPicture(image_name)
   current_image = current_image + 1
  Next
End Sub

i drew one picture control on my form.
im beginner...
elad
try
Set Image1(CLng(Current_image)).Picture = LoadPicture(CStr(Image_name))
Try this:

Set Picture1.Picture = LoadPicture(Image_name)

Since you have drew picture box, the code already given, I think it is for a Imagelist control, if I am right.

Cheers
For your question 2:

For your Sql query,
"select * from tblName where id=?"

try this:
dataenviroment_name.commandname  3

'if need be, Set data control's data source & refresh
:

Hope this helps.

And for checking with your open questions, click on your member profile, (or on your EE id on top Left of EE window) and click Question History and then Questions Asked.

Look for Type column = UnLockedQ or LockedQ in the questions area and click on the questions to clear them.

Thats it.
eladr.. as an Expert yourself, YOU should know what it feels like to have a Questioner steal all of YOUR efforts and then do NOTHING to acknowledge YOUR work, not even leave a Comment. Here is a list of all of your OPEN questions.. which date back into last year (one heck of a lot of (unrecognized by YOU) Expert effort expended on YOUR behalf).  

PLEASE MAINTAIN YOUR QUESTIONS.. before proceeding here.

-----------------------------------------------------------Photoshop:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=photoshop&qid=11361019

Java Programming:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=11668218

Javascript:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=11629258

Visual Basic:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20169023 <-- 0 Point Question
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20165911 <-- This Question

Active Server Pages (ASP)
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20138541 <-- 0 Point
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20122928
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20106442
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20092153
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20091926
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20015553 <-- 0 Point
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20009052 <-- 0 Point
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20000978 <-- 0 Point
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=12014599
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=12013099
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=11691220

XML:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=xml&qid=20009666
https://www.experts-exchange.com/jsp/qShow.jsp?ta=xml&qid=20009049

Macromedia Flash:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=flash&qid=20098609
https://www.experts-exchange.com/jsp/qShow.jsp?ta=flash&qid=20091459
https://www.experts-exchange.com/jsp/qShow.jsp?ta=flash&qid=20074497

Expert Input:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=expinput&qid=10351779
Avatar of eladr

ASKER

i deleted all 0 pts que.(it's references to other que.)
i dont know what to do with the rest of the quetions
because no one give me good answer
elad
Thank YOU eladr.. <smile>

On the other Questions.. just add a comment as to what your current status is.. OR.. what IS LACKING in the Expert response there. If the Question seems dead.. leave a comment.. and then DELETE it.. OR drop a 0 point question in the main forum (like you did here) to draw attention to it again. Do this.. and you might be surprised.. the biggest winner will be YOU.. as most certainly you should get an Excellent answer from a well maintained / run question by YOU.

EXCELLENT Answers to EXCELLENT questions.. that is what EE is all about. Run your questions well.. with lots of comments as to what is lacking so that the Experts can respond.. and EVERYONE wins here.. <smile>.
You said:

i omited the set and still "type mismatch"
this is my code:

Private Sub Form_Load()
 image_name = "c:\elad\eden.gif"
 current_image = 0
 For i = 0 To 2
  Set Image1(current_image).Picture = LoadPicture(image_name)
  current_image = current_image + 1
 Next
End Sub

--------------
And yet the "set" is still there!
Avatar of eladr

ASKER

o.k. wsh2 - i will do it.
for rspahitz
i copy & paste your code and again ...type mismatch...
in this line:
Set Image1(current_image).Picture = LoadPicture(image_name)
i drew 1 image control on the form.
it is o.k.?
elad
Sorry...you misunderstood.  That was entirely your code--an exact quote from your previous comment

However, I reviewed this and apparently it works either WITH or WITHOUT "set" (to my surprise.)

The one thing that came up is that Image1 MUST BE a control array!!!  Ensure that you have three image controls, one with index property = 0, anther with 1, and another with 2

Before I set the index property, I also got the type mismatch.
--
One problem solved.
Avatar of eladr

ASKER

o.k. rspahitz
you have to tell me how to set conrol array
im beginner.
also let's say i dont know how many images names will come from database...
what should i do in this case?
elad
Avatar of eladr

ASKER

o.k.
i set control array and it's working.
but it's dynamic.
what if i have 50 pictures?or a dynamic number that i dont know in advance?...
i can raise pts if needed.
elad
ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eladr

ASKER

i will check it...
and let u know
thanks
Avatar of eladr

ASKER

hi
we are getting closer to the solution.
it's working except one starnge thing.
it's always show me 2 pictures no matter which number i put
in the intTotalImages variable (13 in this case)...
im working in hard code values just to see if it's works
my code is:

Private Sub Form_Load()
 Dim intTotalImages As Integer
 Dim i As Integer
 Dim image_name As String

 ' Figure out how many images to load, based on DB info
 
 intTotalImages = 13 ' currently 2

 For i = 0 To intTotalImages
    image_name = "c:\elad\eden.gif"
    If i > 0 Then
       Load Image1(i)
       Image1(i).Visible = True
       Image1(i).Move (i + 10 * 250) ' move to new location
       'MsgBox i
    End If
    Set Image1(i).Picture = LoadPicture(image_name)
 Next i
End Sub



Avatar of eladr

ASKER

hi
we are getting closer to the solution.
it's working except one starnge thing.
it's always show me 2 pictures no matter which number i put
in the intTotalImages variable (13 in this case)...
im working in hard code values just to see if it's works
my code is:

Private Sub Form_Load()
 Dim intTotalImages As Integer
 Dim i As Integer
 Dim image_name As String

 ' Figure out how many images to load, based on DB info
 
 intTotalImages = 13 ' currently 2

 For i = 0 To intTotalImages
    image_name = "c:\elad\eden.gif"
    If i > 0 Then
       Load Image1(i)
       Image1(i).Visible = True
       Image1(i).Move (i + 10 * 250) ' move to new location
       'MsgBox i
    End If
    Set Image1(i).Picture = LoadPicture(image_name)
 Next i
End Sub



Change this:

Image1(i).Move (i + 10 * 250)

to this:

Image1(i).Move (i * 250)

All images are showing 1 twip apart, which usually gets translated to the same pixel location.
At some point you may want to change the i*250 to a different calculation to cover your row and column, which is why I used .Move rather than .Left.

Also:
1) you may want to have your form set to AutoRedraw=true
2) note that you are getting 14 images, numbered 0 to 13.
Avatar of eladr

ASKER

i will try and let u know.
i will raise pts because of your effort to help me.
elad
Avatar of eladr

ASKER

hi...
everything works great!
u r the best.
the only thing that i should ask is how to make new Line
after the image counter is reach to 5.
i want 5 images & vbnewline & 5 images...etc
thanks
elad
If the images are a fixed size, try something like this:

'...
      Load Image1(i)
      Image1(i).Visible = True
' *** add these lines ***
      ImageLeft = (i mod 5)*250 ' 250 represents image width
      ImageTop = int(i/5)*275 ' 275 represents image height
' *** modify this line ***
'      Image1(i).Move (i + 10 * 250) ' move to new location
      Image1(i).Move ImageLeft, ImageTop
'...
yes, that looks like it'll work... go with rspahitz's answers
Avatar of eladr

ASKER

thanks very much!
please ,i promise it's my last question:
i seems i can resize the picture during running time.why?
i tried
image1(i).width = 120
image1(i).height = 90
but it didnt change.
the only thing that effect the picture is resizing it during design time
when i do it on the control on the form...
but i need to do it during running time.

elad
Avatar of eladr

ASKER

cancel my previous comment
i can control images width & height...
but if i have many images(30,40) i cant see all of them
because i dont know how to set a scroll bar in my form...
How can i do that?
elad
doing a scrollbar in your form isn't a simple task; it probably merits a 50-point question in itself. (if not more).

If you want I can write you some code...
Avatar of eladr

ASKER

tell me more about it.
i thought it should be very simple...
i raised pts to 120.
elad
You have to place the scrollbars in your form, and move ALL the controls contained in your form individually when the scrollbar moves.

Not an easy task.

Most people use a container control and move that, but that requires extra work and has some disadvantages...
Option 1: Following JanusFury's suggestion, You could use a picture box as a container, within another picture box and place all your controls in it, with the picture box stretched first, when design time, beyond the visible level, place the controls in the inner picture box.

Set the Scroll bar's Min property to 0 (inner picture box's normal Top property). And its Max property to picture box's Maximum negative level, so that, all the controls will be visible. So, in Scroll bar's click event, you need to set the Picture's top to Scroll bar's value, but in negative, so that the picture box would move top.

Would you need clarification on this, let me know.

Option 2: You could use a Tab control, and place all your controls in each tab, grouping the controls as needed. This would look nice, and there is not much programming.

Cheers.
Avatar of eladr

ASKER

thanks all of you
pts to rspahitz .
he gave me the core solution.
but, eladr, hope you had 3 questions, as also the title suggests. You have chosen the answer for one question only, if I am right. :)
Avatar of eladr

ASKER

no.
watch the thread - rspahitz gave me the main solution
he gave you the core answer?
O_o
I don't really care about the points, but it doesn't seem that you're paying attention, and if you don't grade fairly, experts may be turned away from you.
I had the first post here, and even rspahitz (who you gave the answer to) stated this:
"JanusFury is correct on all three, but in #2"...
He simply clarified the answers of me and other posters, and you found his clarifications most useful. So, in stating that he 'gave you the main solution', you're making it look to me (and possibly to other experts) that you don't mean what you say. Because you posted FOUR questions at once and then gave someone an accepted answer for clarifying a couple of them...

Glad you got your questions answered, though :)

Just my two cents.
Janus
Janus, you are right. And I hope, I tried for the 2nd question and 4th question, which is also tried by you too.

As you said, though points make the attraction in this site, not always.

Anyhow, eladr got the solution is alright.

eladr,
what did you do for your scroll bar problem? And did your passing parameter to command, work?

Cheers.
Avatar of eladr

ASKER

o.k. guys...
sometimes it's hard to decide which one was right and to give the pts to.
rspahitz was the dominant person in the thread and he gave me code and solution to the nost important one.
but in this case i will open new thread with the subject "pts to JanusFury" and i will give u also pts.
i hope it's o.k. and im sorry...
elad
Ah, it's okay, just be clearer when you give away points, so that people won't feel like they got shafted. :)

"Rspahitz was the most helpful so I'll give him the points. Thanks everyone" would be a good example. :)
Hi, eladr and others.  Just back from vacation.

Thanks for the points, and as JanusFury indicated, you really asked several questions, which should probably have been split into several threads, with points awarded separately.  I feel I was the recipient of some points that should have gone to others (although I certainly  did feel I offered some helpful advice!)

Glad you were able to work it out.