Skip to main content
GameDev.net gamedev.net
🔒 Locked

Visual Basic help

Started by stevem444 Oct 13, 2001 at 2:28 PM 13 replies 650+ views
Original Post
stevem444
stevem444
Hi there, just wandering if someone could spare a bit of time to help me out. Basically, i''ve just started learning VB 6.0 and I would like to program a really simple program that allows people to few my art work. Basically what I need is a program which has a window and allows the person to click next picture and previous picture to view different pictures and a discription. I just need a little help and advice from you more experienced people to help me out. Thanks Steve
stevem444
stevem444
Is this possible, if it is, I would really appreciate a little help from someone! - thanks

Steve
WORF
WORF
Yes, it''s very possible. It''s a perfect app for VB to handle. If you have any questions, please post them on the forum and somebody will be happy to help you out.
...keeping it simple...
stevem444
stevem444
Well to cut it short I need to know how to do this? I''m only a beginner so I only know a few things about it, and I think it may be out of my range of knowledge to do it. I was just wandering if someone could help me with the codeing ect.
WORF
WORF
I'll try to get you going.
Well, you'll need a picture box to display your artwork. And you'll need some way of storing what pictures you want to show and in what order.

I suggest that you have a directory where you put all of your artwork, then when the program starts, it grabs everything from that directory (using dir$()) and puts it in a list (you could use a collection or an array...whatever). Then your program would have two buttons to move through that list and display the pictures.

I'm suggesting that you put them in a directory so that you won't have to make any code changes if you want to add new art. You just put another picture in that directory and your program will automatically display it.

Feel free to email me if you want, but I'd prefer using the forum because it may help other people.

Edited by - Worf on October 13, 2001 5:11:27 PM
...keeping it simple...
TeraByte
TeraByte
Id be glad to help.

I program in VB4 but it should be more less the same.

Can you use the ImageList Custom control? I men does it work with VB6, it should but as i said i use an earlier version of VB.
Anyway, if ou have the ImageList custom control then it is very very easy to make.

If you don''t, you have 2 options (Well, theres more than 2 ways to do it, but thease are the easiest.)
If ou have the IageList custom control skip this:

First method:
Make 1 form for each picture, put an image or picturebox on the form and load your picture into it (or put the picture on the form usig the forms picture property)
The make a command button to go to the next form and previous form usig code like:
Form1.hide
Form2.show

Second method:
You only need oe form. Make an image (or picture box,but lets just say image as an example) for every picture.
Set the visible property for the images to False
Use a variable to keep track of which picture is currently visible.
Private PicNum as Integer
Then make a button for ex and preious, the code for next would be somethig like:
PicNum = PcNum + 1
Select Case PicNum
Case 1
Image1.visible = True
Image2.visible = False
Case 2
Image1.Visible = False
Image2.Visible = True
End Select

Alternativly you could have Image 1 as a control Array so that the first picture is i:
Image1(0)
The second in Image1(1)
etc.
That way your code for the next button would be somehing like:
PicNum = PicNum + 1
Image1(PicNum).Visible = True

Just remember to make the others invisible.

Theres many other ways to do it but the above are easiest.

Ill write the ImageList metod in a seperate post.


"Though i walk through the valley of the shadow of death, iwill fear no evil, for i am the meanest motherfucker in the valley."
stevem444
stevem444
Hi thanks for the starting advice, im gonna have a go at that, and i''ll expect i''ll get stuck on it, so i''ll post back here. Thanks for the help though

cheers

Steve
TeraByte
TeraByte
Worf probably knows more about it than i do, he probably uses VB6 and therfore knows best.
So if he didnt mention the ImageList it may not work with VB6 (or he just didnt think of it, or simply dosnt have it) i dunno.

But ill post my metod anyway.

Get an imagelist, load in all your pictures.
Put a picturebox or imag onto your form (for my example code ill use image)
and finally, two command buttons (Previous ad Next)

The code would look something like:

Private PicNum As Integer ''Current picture varable.

Public Sub Form1_Load()


PicNum = 1
Image1.Picture = ImageList1.ListImages(1).Pictre
Command1.Enabled = False

End Sub


Public Sub Command1_Click() ''Command1 is the Previous button.

Command2.Enabled = True
PicNum = PicNum - 1
If PicNum = 1 Then Command1.Enabled = False
Image1.Picture = ImageList1.ListImages(PicNum).Picture

End Sub


Public Sub Command2_Click()

Command1.Enabled = True
PicNum = PicNum + 1
If PicNum = 10 Then Command2.Enabled = False ''Change the 10 to whatever the amount of pictures you have is.
Image1.Picture = ImageList1.ListImags(PicNum).Picture

End Sub


"Though i walk through the valley of the shadow of death, iwill fear no evil, for i am the meanest motherfucker in the valley."
stevem444
stevem444
erm..simply question i guess, how do you get a image list up??
krez
krez
there are two problems with using a picturelist for this:
1) the pictures must be loaded before you compile the program, so your EXE will be bigger, and
2) you cannot change, add, or remove any pictures afterwards without re-compiling the program.
i wrote a program which does this, for my non-computer-friendly family to look at digital photos without bugging me .
you click a thumbnail of the image, and it pops it up full-screen. you can also pick different directories, and whatnot. i can send you the source if you like.
of course, writing it yourself will teach you more.

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
stevem444
stevem444
Hi Krez, cheers for replying, that would help me if you could send me some source, then I could use that if I get stuck.

Thanks mate

my email address is stevem444@hotmail.com

TeraByte
TeraByte
You could have a load picture command button so that you canload additional pictures.
Were getting more complicted by the minute...
The main reason i opted for the ImageList to do the job is because its the simplestmethod i could think of,
and we are tryig to help a BEGINNER.
I realize that the EXE file will be big but the coding is simple.

If were writing the program id allow the user to load in picures at runtie and store the path
in a file (picturelist.ini) or something like that, so that everytime you run the program
it loads up all the pictres you added, and you could easily modifythe file if you want to manually delete a picture
though id have an option to do that automatically.
Alternativly, the program could copy te pictures into the same folder as the program is
so that it could load any Bmp, gif, jpg, jpeg etc file which are in the app.path directory.

Use the (kernel32 i think) CopyFile API to copy the picture.
Or use a search for file API(i think i seen one the other day when i was looking through my API reference)

But that would be too complicated for a beginner
"Though i walk through the valley of the shadow of death, iwill fear no evil, for i am the meanest motherfucker in the valley."
stevem444
stevem444
okay cheers Krez - I appreciate it. And also thanks to everyone else who has given me suggestions on how to do it. I''ve copyied and pasted all the info everyones given me to experiment on!

Cheers

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.