Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Filename

Status
Not open for further replies.

YoshiCD

Programmer
Feb 24, 2001
96
ES
How can I load the filename of an existing image into a variable???
If anyone can help, a Virtual Pint in the bar is the reward... Thanks millions to those who try...

Tx.. ¥oshiCD (Confuzzed)
 
John,

That is simple enough, but I'm loading 60 images into an array and need to single out one image when maintaing the image database, the image I need to single out is the one that is on the form already, which was loaded by using the commondialog control, the simple option out is to create another database that updates when the image is updated, but i wanted to see if it was possible to just use a single variable inside the program without having to access another file...

Please help me again...
Regards,
¥oshi
 
Why don't you load them into a listbox?

Here's some sample code. NOTE: You may need to change the path to the BMPs being used as examples here. I'm sure you can capture the paths as they come in from the cdl control.

==start code here==

VERSION 4.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5940
ClientLeft = 1140
ClientTop = 1515
ClientWidth = 6690
Height = 6345
Left = 1080
LinkTopic = "Form1"
ScaleHeight = 5940
ScaleWidth = 6690
Top = 1170
Width = 6810
Begin VB.CommandButton cmdOnOffSwitch
Caption = "List-on"
Height = 375
Left = 4560
TabIndex = 4
Top = 480
Width = 855
End
Begin VB.CommandButton cmdLastImg
Caption = "Previous"
Height = 375
Left = 3000
TabIndex = 3
Top = 1080
Width = 855
End
Begin VB.CommandButton cmdNextImg
Caption = "next"
Height = 375
Left = 3000
TabIndex = 2
Top = 480
Width = 855
End
Begin VB.CommandButton cmdExit
Caption = "Exit"
Height = 375
Left = 4560
TabIndex = 1
Top = 1080
Width = 855
End
Begin VB.ListBox List1
Height = 1035
Left = 480
TabIndex = 0
Top = 360
Width = 1935
End
Begin VB.Image Image1
Height = 2415
Left = 480
Stretch = -1 'True
Top = 1920
Width = 4935
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdLastImg_Click()
If List1.ListIndex - 1 = -1 Then
List1.ListIndex = 0
List1_Click
cmdLastImg.Enabled = False
cmdNextImg.Enabled = True
ElseIf List1.ListIndex - 1 > -1 Then
List1.ListIndex = List1.ListIndex - 1
List1_Click
End If
End Sub

Private Sub cmdNextImg_Click()
If List1.ListIndex + 1 <= List1.ListCount - 1 Then
List1.ListIndex = List1.ListIndex + 1
List1_Click
ElseIf List1.ListIndex + 1 > List1.ListCount - 1 Then
List1.ListIndex = List1.ListCount - 1
List1_Click
cmdLastImg.Enabled = True
cmdNextImg.Enabled = False
End If
End Sub

Private Sub cmdOnOffSwitch_Click()
If List1.Visible Then
cmdOnOffSwitch.Caption = &quot;List-off&quot;
List1.Visible = False
Else
cmdOnOffSwitch.Caption = &quot;List-on&quot;
List1.Visible = True
End If
End Sub

Private Sub Form_Load()
'make sure you have some BMPs in Windows to load or you'll get an error
List1.AddItem &quot;C:\Windows\setup.bmp&quot;
List1.AddItem &quot;C:\Windows\circles.bmp&quot;
cmdLastImg.Enabled = False
End Sub

Private Sub List1_Click()
Image1.Picture = LoadPicture(List1.List(List1.ListIndex))
End Sub


==end code here==
As you'll see, you can turn on/off the list box. You won't have to create a seperate file. New ones can use the AddItem. Update can use NewIndex to resequence them.

If this helps any click the &quot;Helpful Tip&quot; below my name.
--MiggyD &quot;The world shrinks more and more with every new user online.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top