Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Show Random Pictures In A Form


I, first at all, excuse me for my bad english.
I'm doing a quiz game, and every time a load a form, called frmplayer1, i want the imgplayer1 show random from a folder with various gif's.

Example: the form of 1 player load and my character is a doctor. But i have a folder with other images (gif). I want the game choose random my character.

Thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Random Pictures.
Hi Everybody:

How can I do to change automactically between two or three pictures inside a picture box?
I'm triyng the code below but its change the tho pic at the same time.

-------------------------
Private Sub timLogIma_Timer()

pic.Picture = LoadPicture("c:pic1.bmp")
pic.Picture = LoadPicture("c:pic2.bmp")

------------------------
End Very thanks!

Random Pictures?
I was trying to make a program where 1 picture was taken at random from 56 pics and the only way i know how to do random stuff is through random numbers (call randomized) and i was wondering if there was an easier way of doing this

is there?

Not So Random Pictures
Hi there, as a folow up to a different thread I have a program that when you press a button it picks a random picture.

I was wondering does Vb allow you to randomly pick a picture, and then do not pic it again as long as the program runs. So in a sense it only allos it to be picked one and then does not randomly pick it?

I used this code to randomly pick a pic


VB Code:
Option ExplicitPublic randomPic As Integer Dim Images() As IPictureDisp Private Sub Command1_Click()Timer1.Enabled = True 'turn the timer on if the button is clickedrandomPic = Fix(Rnd * 15)Set Image1.Picture = Images(randomPic)End Sub Private Sub Command2_Click()Timer1.Enabled = FalseEnd Sub Private Sub Form_Load()  ReDim Images(14)  Set Images(0) = LoadPicture(App.Path & "Popsicle.bmp")  Set Images(1) = LoadPicture(App.Path & "BigTV.bmp") Set Images(2) = LoadPicture(App.Path & "Clock.bmp")   Set Images(3) = LoadPicture(App.Path & "BaseballBat.bmp")   Set Images(4) = LoadPicture(App.Path & "Basketball.bmp")   Set Images(5) = LoadPicture(App.Path & "Soccerball.bmp")   Set Images(6) = LoadPicture(App.Path & "Skateboard.bmp")   Set Images(7) = LoadPicture(App.Path & "Chips.bmp")  Set Images(8) = LoadPicture(App.Path & "Popcorn.bmp")   Set Images(9) = LoadPicture(App.Path & "Newspaper.bmp")   Set Images(10) = LoadPicture(App.Path & "Cheeseburger.bmp")   Set Images(11) = LoadPicture(App.Path & "Lamp.bmp")   Set Images(12) = LoadPicture(App.Path & "Donut.bmp") Set Images(13) = LoadPicture(App.Path & "Laptop.bmp")  Set Images(14) = LoadPicture(App.Path & "Coke.bmp")       End Sub Private Sub mnuExit_Click()Unload MeEnd Sub Private Sub Timer1_Timer()        If Label1.Caption = "0" Then 'if it reaches 0 then...            Timer1.Enabled = False 'turn this timer off            MsgBox "Done!" 'message box display "done"        Else            Label1.Caption = Label1.Caption - 1 'countdown            End IfEnd Sub


Could I add an if then statement, so that IF the loadpicture was "Cheeseburger" then it would pick a new one if it was already chosen?

Thank you

Random Pictures
Hmm i was thinking about this how can I use Randomize but only for picture box's. For example maybe having a different picturebox be visible each time the program is open..

Random Pictures
Hi i want to load an unknown filename picture from a directory (MY Photos) .I don't know the name of those pictures in the directory because the user put his own pictures.But the user can load a picture to a Image control an it as to be at random.
I got a code here but it does'nt works every time, sometime the picture appears and sometime's not.Why?


Private Sub Command2_Click()
Image1.Picture = LoadPicture(GetRndPicFile(App.Path & "My Photos"))

End Sub



Private Function GetRndPicFile(sFolder As String) As String
Dim sFile As String
Dim s As String

Dim calle() As String
Dim i As Integer
Dim r As Integer

'seed the rnd function for better randomization
Randomize

'get all the jpg files found in the given folder into an array
sFile = Dir(sFolder & "*.jpg")
Do While sFile <> ""
s = s & sFolder & "" & sFile & vbCrLf
sFile = Dir
Loop
calle = Split(s, vbCrLf)

'pick one of the files at random
r = Int(Rnd * (UBound(calle) + 1))
GetRndPicFile = calle(r)
End Function

Random Pictures
hello t here!!!
Can anyone please give me the code on how to put a random picture whenever i load a form?

I mean for eg.. i have a picturebox named picture1.. what if i want to put different pictures at form load...?

Random Pictures
well, i wanted to random out 2 pictures of the same from a folder say;
pic1, pic1, pic2,pic2,pic3,pic3,etc...

how can this be done?
below is my code: (you can try running it.)
and my problem is that it randoms 1 or more than 2 pics of the same. (but i wanted to random out two)


Code:
Option Explicit

' Global variables hold the total number of columns and rows
Private TotalCols As Integer
Private TotalRows As Integer

Private Sub Form_Load()
' You must have an image on the form with the following properties:
' .Name = imgControl
' .Index = 0
' .Visible = False
' .Strech = True
' Set the picture property to something (a bitmap, icon, etc.)

TotalCols = InputBox("How many columns do you want?", "Set Columns", "4")
TotalRows = InputBox("How many rows do you want?", "Set Rows", "4")

Call LoadImagesOnForm
End Sub

Private Sub LoadImagesOnForm()
Dim ImgCount As Integer
Dim RowCount As Integer
Dim ColCount As Integer
Dim FrmScalHghtDiff As Integer
Dim FrmScalWdthDiff As Integer
Dim ErrorMsg As String
Dim i As Integer, num As Integer, k As Integer
Dim filepath As String

With Me

' These loops load images by rows first, then columns, like this:
' 1 2 3
' 4 5 6
' 7 8 9
For RowCount = 1 To TotalRows
For ColCount = 1 To TotalCols
ImgCount = ImgCount + 1

Load imgControl(ImgCount)
'----------------------------------------------------
Randomize Timer 'here is the problem...
k = TotalRows * TotalCols
num = 1 + Int(Rnd * k)
filepath = "C:Unzipped Filesmemory2Icons" & "im" & num & ".ico"
imgControl(ImgCount).Picture = LoadPicture(filepath)
'-------------------------------------------------------
With imgControl(ImgCount)
.Move (ColCount - 1) * imgControl(0).Width, _
(RowCount - 1) * imgControl(0).Height


.Visible = True
End With ' imgControl(ImgCount)
Next ' ColCount
Next ' RowCount

End Sub

Random Pictures
I would like to know how I can display a random number of the same picture. for example if the random number is 3 it will display one picure 3 times next to each other.

Do I use 1 picture box, or a picture box for each possible picture???

I am a new user with Visual Basic so any help is greatly appreciated.

Loading Random Pictures
Hi,

I'm currently working on a project that involves loading random graphics (all located in one current directory) into a picture box. Each graphic file has a separate text caption (which is inside a different file) that corresponds to the graphic. What I'd like to be able to do is load a random graphic along with this corresponding text caption onto the form and continue to do this everytime I click on a certain [display random graphic] button. I realize I will most probably need to be making a two dimensional array to keep track of the information. If anyone has any efficient strategies on how to handle this, I'd be very appreciative to hear them.

Thanks,
-zm

Generating Random Pictures
Ok, So i have a big picture box on a form which will work as the battle background for a turn based game I am making. I want it to load one of the random backdrop pictures i have on form load.


So heres the code I have made so far, but it does not seem to work. This is important because I dont want to have the same background on every fight and im not using multi forms just to battle with different backdrops.



Someone help





Code:
Const MAX_BACKGROUND As Integer = 10
Dim bgArray(MAX_BACKGROUND - 1) As String


Private Sub Form_Load()

InitBackground
SelectBackground
'This just displays a name they entered
nameShow.Caption = ReadINI("config", "CharName", App.Path & "config.ini")
End Sub

Private Sub InitBackground()
bgArray(0) = "backdrop1.jpg"
bgArray(1) = "backdrop2.jpg"
bgArray(2) = "backdrop3.jpg"
bgArray(3) = "backdrop3.jpg"
bgArray(4) = "backdrop3.jpg"
bgArray(5) = "backdrop3.jpg"
bgArray(6) = "backdrop3.jpg"
bgArray(7) = "backdrop3.jpg"
bgArray(8) = "backdrop3.jpg"
bgArray(9) = "backdrop3.jpg"
End Sub

Private Sub SelectBackground()
Dim RandomNumber As Integer
RandomNumber = Random(0, MAX_BACKGROUND)



Dim curPath As String
curPath = "graphics"
BattleScreenPicture.Picture = LoadPicture(curPath + bgArray(RandomNumber))

End Sub

Function Random(Lowerbound As Long, Upperbound As Long)
Randomize
Random = Int(Rnd * Upperbound) + Lowerbound
End Function

How Can I Generate Random Pictures?
i am currently working a game. i draw out imageboxes named "imgControl" (using index property) in a form.
my problem is how can i generate random picked pictures that are stored in a folder and display them in the imgControl during run-time? (by the way the random pictures must be picked up twice) e.g: picA picA, picD, picD.

How Can I Generate Random Pictures?
i am currently working a game. i draw out imageboxes named "imgControl" (using index property) in a form.
my problem is how can i generate random picked pictures that are stored in a folder and display them in the imgControl? (by the way the random pictures must be picked up twice) e.g: picA picA, picD, picD.

How To Show A Sequence Of Pictures?
Hello people

I'm using the code below to change pictures into the picBox, but how could I do this in sequence?
Pic1 -> pic2 -> pic3 -> pic4 and back to pic1 etc?

Very Thanks:

------------

I = Int(Rnd() * 4)
Path = "c:TeleComCadLog" & I & ".bmp"
picLogIma.Picture = LoadPicture(Path)

-------------

Show/Hide Pictures In IE
Hello all,

Here is my requirement:

My application will open Internet Explorer and will navigate to a website. Before that, the application should hide the pictures in IE after navigating to that website do some process and then show the pictures.

My exact requirement is check and uncheck "Show Pictures" option in IE (Tools > Internet Options > Advanced Tab)

Please let me know if there is a way to achieve that.

thanks

Pictures Dont Show Up Well
I cant get my JPEGs to show up clearly in either image boxes or picture boxes. They always look distorted and like garbage. The problem is NOT with the picture. It looks just fine otherwise. Is there some secret that I am unaware of when using pictuer boxes and image boxes?

How To Show Pictures In Datareport
dear all,

How to show the pictures in the datareport...
I stored the pictures in Binary format in Access database..
looking for u r reply
Thanks
Kumar

Program To Show Pictures For Different Selections
I am trying to make it show the player picture and team logo from choosing the player in a combo box. I have it setup to input all the stats to the various boxes. I think that I would have to make another column in the database for team name and player picture or something like that. Can someone give me an example of how to make this work. Here is the code I have for my form so far that is all working, you would just need the database to see it.

--------Code---------

Public db As Database, rs As Recordset

Private Sub cmdExit_Click()
Dim result As Integer
result = MsgBox("Are You sure?", 36, "Do you want to leave?")
If result = 6 Then
End
End If
End Sub

Private Sub cmdShowStats_Click()
Set db = OpenDatabase("a:AllStarStats.mdb")
strSQL = "SELECT * from AllStarStats where playername = '" & Combo1.Text & "'"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
txtAverage.Text = rs("Average")
txtGamesPlayed.Text = rs("GamesPlayed")
txtAtBats.Text = rs("AtBats")
txtDoubles.Text = rs("Doubles")
txtTriples.Text = rs("Triples")
txtHits.Text = rs("Hits")
txtTotalBases.Text = rs("TotalBases")
txtRunsBattedIn.Text = rs("RBI")
txtWalks.Text = rs("Walks")
txtStrikeOuts.Text = rs("StrikeOuts")
txtOnBasePercent.Text = rs("OnBasePercent")
txtSluggingPercent.Text = rs("SluggingPercent")
txtOnBaseSlugging.Text = rs("OBS")
txtHomeRuns.Text = rs("HomeRuns")
txtRuns.Text = rs("Runs")
End Sub
Private Sub Form_Load()
Set db = OpenDatabase("a:AllStarStats.mdb")
strSQL = "SELECT * from AllStarStats"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Do While Not rs.EOF
Combo1.AddItem rs("PlayerName")
rs.MoveNext
Loop
End Sub

---------End Code-----------

Webbrowser (show Pictures Property?)
The following thread has been posted by vidyaishaya and I have the same problem. Here's his thread:



I have "discovered" that the following code:
HTML = WebBrowser1.Document.documentElement.innerHTML
will give me the contents of the HTML on a page using the WebBrowser object.

So... the WebBrowser object is obviously closely related to the Internet Explorer installed on a machine.

Is there any other properties (or a list of properties) of the WebBrowser that aren't commonly available...

What I'd really like to do is set the "Turn Graphics Off" for the WebBrowser without having to instruct the user to go to the Internet Explorer and:

In the Tools menu, select Internet Options. Use the Advanced tab, go to the multi-media section, and uncheck Show Pictures.

Can I get at the Internet Options -- Advanced -- properties directly from VB??

Thanks. ....Vidya and Krass =)

(VB6)Show Pictures In PictureBox Randomly
Hon'ble gurus,
I use VB6, PictureBox and Imagelist and a timer. I have 3 different categories of pictures in 3 different ImageLists. I have 3 ImageBoxes on the form. I want to see all the images of the Imagelists in the ImageBoxes randomly. Will it be possible? If yes, please help me. Thanks and regards.



pkb_pkb

How Can I Not Show The Pictures Until User Click On The Imagebox?
i loaded array of pictures into imageboxes during runtime. how can i not showing the pictures until the user click on the imagebox?

WebBrowser Control - How To Turn 'show Pictures' On And Off?
Hello !

Internet Explorer, under tools->Internet options-> advanced ->multimedia, has a check box titled 'show pictures'. This can be used to command the browser to avoid automatic image download when browsing the web.

How to turn 'show pictures' on and off in webbrowser application?

Thank you in advance!
Gave a nice day!

HOW TO SHOW PICTURES STORED IN THE DATABASE WITH DATAREPORT_
Hi Everybody
I AM TRYING TO CREATE A REPORT THAT CAN SHOW PICTURES STORED IN THE DATABASE ALONG WITH OTHER FEILDS. I TRIED USING THE REPORT IMAGE CONTROL BUT AS THE REPORT IMAGE CONTROL DO NOT HAVE DATASOURCE,DATAMEMBER AND DATAFEILD PROPERTIES. I AM WONDERING IF SOME ONE CAN HELP ME ON THIS.


thanx

HOW TO SHOW PICTURES STORED IN THE DATABASE WITH DATAREPORT
Hi Everybody
I AM TRYING TO CREATE A REPORT THAT CAN SHOW PICTURES STORED IN THE DATABASE ALONG WITH OTHER FEILDS. I TRIED USING THE REPORT IMAGE CONTROL BUT AS THE REPORT IMAGE CONTROL DO NOT HAVE DATASOURCE,DATAMEMBER AND DATAFEILD PROPERTIES. I AM WONDERING IF SOME ONE CAN HELP ME ON THIS.



Edited by - samaniegocd on 7/12/2003 9:20:18 AM

Show Pictures In A Folder Using A Command Button
I need to show a different picture everytime the command button is clicked. How can I tell the command button where to get the pictures from.
I know how to use DriveListBox, DirListBox, and FileListBox, but I would like to try something different.

Need Help - How To Show Random Text
Hi all, good day!

I have a problem with vb6. I need to show random text in a lable or text box. that means, If command1 button click text box show another text from predefined text list. this must show when program start also. I mean,

ex: If user open once it display "Hello" after that he open the program in next time it will display "Howdy" etc.

Random text is must in the program like

Hello
Howdy
LOL

I am so confusing of this. Please some one help me. I am a new comer to vb6. I need your help please.

Thanks & Have a Nice day!
gymamal

Random And Sequential Slide Show
I am having trouble with this random and sequential slide show code, it reads the stored array elements, and creates a slide show with it. Here is the code. Disregard the commented out code.


Private Sub fsequential_Click()
showType = "Sequential"
Timer1.Interval = 5000
End Sub
(the same is for a random button)
Private Sub Timer1_Timer()
If showType = "Sequential" Then
Image1.Picture = LoadPicture(myphotos(i).Location)
i = i + 1
If i &gt; nPhotos Then i = 1
End If
'If showType = "Random" Then
'Image1.Picture = (Rnd * (myphotos(i)))
'End If
' another if block for Random ShowType
'End If
Call Showimage(ind)
End Sub

Sorry for the long post

Show Random Stored Number
I have a button and a text box, I want it so when they click the button one of the group of numbers I have stored in it will show.

So lets say I have theese numbers as an example: 32154, 76783 and 11215, I click the button and than the number 76783 comes up, so I click the button again and I get 32154 I click again and I get 11215 and I click again and I get 32154 again since it only has those 3 groups.

I was thinkin maybe variables? and sum how set it to randomly show? I dont know howto exactly, I am sure it has been done before though.

Kinda Stuck... {show Random Text From List}
Hey guys im kinda stuck. I am trying to make a random insulter in Visual Basic 6.0 and i want it to be able to say a difforent insult out of the 100 that i put into the code every time i click the command button. I want the insult to come up in a text box.

I hope you guys can help me.

Thankyou.

Two Q's - Changing Tab Order && Getting A Random Variable To Show Up At Another Text B
1. I have 20 text boxes.. they are each named p1-p20. How can I make it so the tab order goes through them in order (1-20)?

2. I have this code:

When I press a button (pickwinner) I want the text inputted in one of the twenty text boxes that I have (p1-p20) to display in the text box called winner.text.. How can I do this? Thanks!

Is It Possible To Show A Vb Form Over A Power Point Show?
I need your help.

This is the scenario, I am playing a power point show and
I want a form be shown so that I can click on a command button

how do i do this? is this doable?

i need suggestions as soon as possible.

thanks

Random Refresh Of Drawing Surface Causes Background Color To Show
I'm using directdraw7 to display my game. I'm having an issue when the game is windowed.

My render chain works like this: back buffer->front buffer (associated with picturebox)

I've just noticed that occasionally - say, once every ten seconds, the picturebox that I'm blitting to will 'refresh' and re-paint itself... displaying the background color that is normally behind the game graphics.

Is there a way to stop this from happening?

Alternatively, I suppose I could use the BltToDC function, and draw directly from the back buffer to the picturebox... is this slower than the normal process?

Form Does Not Show Using FrmForm2.show
I have two forms named form1 and form2.

I placed cmdButton to navigate to from 2:

load form2
form2.show

When program runs and navigate to form2, form2 does not pop up on the screen, and the program ends. Why? What I did wrong?

Form.show Wont Show
Hello,
When Ive loaded several childforms on an MDIForm, I cant
make one of the already loaded show again by the .show method.
It stays behind the other forms.
Is there another way?
Thanks!
ChicHo

Show Form When Message Box Show?
Hi all. i have two forms.
form1 property:
ShowInTaskBar=True
form2 property:
ShowInTaskBar=False

'code in form1:
Private Sub Form_Click()
Form2.Show
End Sub

'code in form2:
Private Sub Form_Click()
MsgBox "Show Form!"
End Sub

Form1 is StartUp. When I click In form2 the message box show and the form2 two always run to back of form1. But i want form2 with message stand still.
someone please help me? many thank for your help.

Correction: Form Does NOT Show Using Form.show
I have two forms named form1 and form2.

I placed cmdButton to navigate to from 2:

load form2
form2.show

When program runs and navigate to form2, form2 does not pop up on the screen, and the program ends. Why? What I did wrong?

How Do I Hide Half Of A Form And When A Command Button Is Clicked I Show The Rest Of The Form??
how do i hide half of a form and when a command button is clicked i show the rest of the form??

Show A Form On Top Of Another Form, But Keep Focus On The Lower Form?
I've attached a picture of a scheduling section for my applicaiton. The Tooltip window is a seperate form with transparency and no border. I would like the form to show on top of the scheduling form as in the screenshot, but I want the focus to remain on the lower form.

I have seen code somewhere that does this but I can't seem to find it anywhere?

Child Form Opens Up At Random In MDIparent Form
My VB6 application follows the MDI format. I have several child forms under the parent MDIform. Whenever i click search button in the my main child form, other child form also opens up. I dont know how to stop unwanted child form to open up at random. Could someone please help. thanks.

Child Form Opens Up At Random In MDIparent Form
My VB6 application follows the MDI format. I have several child forms under the parent MDIform. Whenever i click search button in the my main child form, other child form also opens up. I dont know how to stop unwanted child form to open up at random. Could someone please help. thanks.

Pictures In A Form
hi, can anybody tell me the code for inputing an image into a running form or how to go about doing it? It is for a housing survey application and I need to input a picture to the house details. the application does not have a database, it only stores the data in arrays. NB I am a beginner in VB o go easy on me please....
Andy

Form Pictures
I am having a problem deleting a picture I placed on my form. I can't delete it from my form through the properties window or by right clicking on it.

So Many Pictures On One Form !
I want to display 75-80 small pictures of about (120 x 96) pixels in size on a form such that only 9 of them are displayed at a time and more can be viewed using vertical scroll bars. When I tried to do so I was able put only 12 images because size of the form is limited to 9000 only.

Can anyone tell me how to do this?

Thanks.

Getting Text To Show Highlights On Form Behind Form In Focus
Title sounds kind of funny. I'll see if I can explain better.

With my text editor, when I have the (Find/Replace) Form up, and I do a Find or Replace... I have it coded to "highlight" the text using .SelLength, however, it doesn't show the text as selected until I switch focus BACK to the main form (by clicking on it, or tabbing). When I click (or tab) back to the find box, the highlighting goes away.

For example, open up Notepad and paste some stuff in it, do a "Find", you'll see when it finds the text, it will be highlighted while the Find box is still in focus.

This is how I'd like my application to behave. Any ideas?

I'm using a RTB control.

Show A Form Without Main Form Running Code
I'm trying to show a form (frmDriveSelect), but I don't want any code to run in the main form until the form I open (frmDriveSelect) closes. Any ideas? I tried "Show vbModal, frmDriveSelect" but that says form is already showing, which it isn't.

Can I Show Form Icon When Form With No Border Is Minimized?
Hi,
I am trying to find a way to display form's icon when a form without title bar is minimized. Or, if that can't be done, then change form border property when minimized and restored back.
Can somebody help me?
Any idea appreciated
Thanks,
akrep

How Do I Show A Form Without The Parent Form Showing At Top Of The Z-order
How do I show a form without the parent form coming to the front of the z-order.

i.e.

frmParent is restored but behind another application. I then execute the following code.


Code:
frmchild.visible = True


The frmParent does not come in front of previous app.

Printing Pictures To A Form
I want to make a map editor and I need to put tiles down on the form somehow. I guess I could use pictureboxes but Isnt there a way to combine pictures either a form or picturebox?

Help! Move Pictures Around A Form
hi please can some1 tell me how i can make pictures movable on a form

Thanks
PCUser

Cannot Get Pictures To Diplay In MDI Form
Could someone please help me! I've spent the past week trying to figure this out on my own, to no avail.

I have a simple MDI form, and in one of the child forms I have a combo box that when selecting an EquipTagNo from the combo box the relevant fields are filled. I have the textboxes and checkboxes filling, but I can't get the pictures to show.

I'm declaring the pics as 'private mpicPicture1 as PictureBox'...not sure if this is right.

Also I'm using an Access table to hold my information, and for the picture and drawing fields I'm using a 'hyperlink' to the source destination to store the photos. Is this right? I think I have everything coded properly...could someone please take alook at my code and explain what's wrong...or at least give me some insight?

I'll post the complete project zipped. (it's not too big) You'll fiind the problem occuring with the Equip form.

Thanks to all....

Copyright © 2005-08 www.BigResource.com, All rights reserved