display pic
display pic
display pic
display pic
display pic
display pic display pic display pic display pic display pic display pic display pic display pic
display pic display pic
display pic
Go Back  Xtreme Visual Basic Talk > > > display pic


Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2004, 01:26 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Question display pic


hi
im trying to create a bandit program,like those u get in arcades
and i will get it to generate the pics but i want no how to disply the pic

i mean i will have three picture boxes and they each will need to display 1 of 3 pictures how can i do this.
Reply With Quote
  #2  
Old 08-22-2004, 06:49 PM
bear24rw's Avatar
bear24rw bear24rw is offline
Contributor
 
Join Date: May 2004
Location: NJ
Posts: 477
Default

Code:
Dim X As Integer Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click X = Int(Rnd() * 3) ' pick a number.... 0, 1 or 2 Select Case X Case 0 picbox.Image = Image.FromFile(Application.StartupPath & "/pic1.bmp") Case 1 picbox.Image = Image.FromFile(Application.StartupPath & "/pic2.bmp") Case 2 picbox.Image = Image.FromFile(Application.StartupPath & "/pic3.bmp") End Select End Sub
try that
__________________
Use[vb][/vb] tags when posting code.

Last edited by bear24rw; 08-22-2004 at 06:56 PM.
Reply With Quote
  #3  
Old 08-23-2004, 02:57 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

how do i put in my the filename and location of the pic

and should i put the pic anywere in paticular

thanks
Reply With Quote
  #4  
Old 08-23-2004, 03:17 PM
bear24rw's Avatar
bear24rw bear24rw is offline
Contributor
 
Join Date: May 2004
Location: NJ
Posts: 477
Default

i dont exactly understand what you mean...
if you have the picture, lets say in a folder called pics on the hard drive you would put
Code:
picbox.Image = Image.FromFile("C:\pics\pic1.bmp")
application.startuppath returns the file from witch you are running your program... by defult when you compile with VB it goes in the bin folder. so if you put your pictures in the bin folder, application.startuppath would give you the location of the .exe and you just add the picname to it. useing application.startupath is alot easier cause you dont know where the user is going to put the folder with the .exe (unless you use an installer)
so basicly put the pics in the BIN folder
hmm... yeah sry if thats a really bad explination, but its really not that hard to understand what application.startuppath does
__________________
Use[vb][/vb] tags when posting code.
Reply With Quote
  #5  
Old 08-25-2004, 04:59 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

i put in that code, put in my filenames but theres an error it highlights the button 1
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

it ses handles clause requires a with events variable?

this is probly sumink really simple but i dont no so..........
Reply With Quote
  #6  
Old 08-25-2004, 05:24 PM
lebb's Avatar
lebbdisplay pic lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Do you have a button on your form named Button1? Do you already have another event that's handling it?
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #7  
Old 09-02-2004, 03:43 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

Quote:
Originally Posted by lebb
Do you have a button on your form named Button1? Do you already have another event that's handling it?
nope only the 1 button which starts the code
Reply With Quote
  #8  
Old 09-02-2004, 03:50 PM
lebb's Avatar
lebbdisplay pic lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Is that button named Button1?
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #9  
Old 09-02-2004, 09:57 PM
Iceplug's Avatar
Iceplugdisplay pic Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If this event has the code that you want to run when the button is pressed, you need to replace Button1 with the name of the button that you have.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #10  
Old 09-03-2004, 02:31 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

ok ive got the pics to show up properly but now im working on gettin a label to show a figure depending on if the player gets three wins
this is what i put in
If PictureBox1.Image Is "c:/pics\win.bmp" and
PictureBox2.Image = "c:/pics\win.bmp" and
Picturebox3.Image = "c:/pics\win.bmp" then
Label2.Text = Label2.Text + 5
and it cums up wid

expression expected
expression expected
end of statement expected
value of string cannot b converted to system.drawing.image

help plz
Reply With Quote
  #11  
Old 09-03-2004, 02:34 PM
lebb's Avatar
lebbdisplay pic lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Two problems that I see immediately:

1) VB statements need to be all on one line. If you want to break up the conditions in your If statement onto separate lines, you must have line continuation characters (" _") at the end of each line that breaks to the next line, so that the compiler knows to combine them in order to evaluate the statement.

2) You've got forward-slashes in your paths in some places where you should have backslashes.

[edit]
Make that three problems. Once an image is loaded, the system keeps no record of where it came from. You can't compare an image to a string. Perhaps whenever you load a picture, you could put its path in the .Tag property of the picturebox; then use that to compare with when you need it. Just a thought.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #12  
Old 09-04-2004, 03:18 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

its probly really sinmple but how do i put it in the .tag property?
Reply With Quote
  #13  
Old 09-04-2004, 07:25 PM
Iceplug's Avatar
Iceplugdisplay pic Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

When you put a picture into the picturebox, you can assign the path to the tag. If you are putting them in at design time, then you'll have to put the tag in at designtime.

PBox.Image = Image.FromFile(filename)
PBox.Tag = filename
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #14  
Old 09-05-2004, 04:12 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

but the pictures will b changing everytime so can i put the code in after the assingning of pictures

alrite im probly the only1 that understood that

as im assinging the pictures to the pic boxes can i change the tag everytime
im not sure if thats what i mean lol
Reply With Quote
  #15  
Old 09-05-2004, 08:15 PM
Iceplug's Avatar
Iceplugdisplay pic Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Yes, whenever you "assingn" a picture, you can assign the path that you loaded the picture from to the tag property.
Just what I had above.

Or, you can load all of the pictures into an image array, load the pictures from the array, and just store the index of the array where you just loaded the picture from.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #16  
Old 09-06-2004, 01:57 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

so if 1 pic was c:/pics\win.bmp then would i put this

PictureBox1.Image = Image.FromFile(c:/pics\win.bmp)
PBox.Tag = c:/pics\win.bmp

or have i got it wrong
Reply With Quote
  #17  
Old 09-06-2004, 02:22 PM
lebb's Avatar
lebbdisplay pic lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Yes, except you need your paths in double-quotes, and I still think you may have problems because you're using forward-slashes where you should have backslashes.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #18  
Old 09-07-2004, 03:08 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

so if i put all the c:/pics\win.bmp and change um to "c:\pics\win.bmp"
it should work

ok put it all in and problem appears
i do the compareing which seems to work the at the end of it i want it to add 5 to the bank so i put
label2.text=label2.text+5
this has worked b4 but it sese "" double is not allowed or similar

help again lol plz

Last edited by just_for_fun; 09-07-2004 at 03:56 PM.
Reply With Quote
  #19  
Old 09-07-2004, 04:56 PM
ZooTV's Avatar
ZooTV ZooTV is offline
Junior Contributor
 
Join Date: Jun 2004
Location: Venezuela
Posts: 265
Default

try Label2.Text = (CInt(Label2.Text) + 5).ToString
I'm supposing you want to add integer values.
__________________
ZooTV - Inferi
Reply With Quote
  #20  
Old 09-10-2004, 02:16 PM
just_for_fun just_for_fun is offline
Freshman
 
Join Date: Aug 2004
Posts: 33
Default

Nope that doesnt work either
if what i think 3 wins cum up then error message ses
Additional information: Cast from string "" to type 'Integer' is not valid.
Any ideas
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
display pic
display pic
display pic display pic
display pic
display pic
display pic display pic display pic display pic display pic display pic display pic
display pic
display pic
 
display pic
display pic
 
-->