Jump to content

Creating an image viewer in Visual Basic

- - - - -

  • Please log in to reply
5 replies to this topic

#1
blueparukia

blueparukia

    Newbie

  • Members
  • Pip
  • 3 posts
Now, basically, I want to make a VB program that can recognise custom file types (not really custom, more on that later).

Basically, there are 2 crucial elements I am missing.

1. The ability to view images. Using Microsoft VB6, what type of object do I want to add for the images to display in, and what code do I need?

2. Reading a semi-custom file extension. Say I have renamed a file from: image.png to image.dgn for example. It is still a png image, but has a different name. So when you press cmd_open I need it to browse only for files that have the .dgn/.dgnet extension, and open them as .pngs.

I haven't used VB for 3 years now, and am VERY rusty. I can't even remember how to make a browser box to open files :confused:


Can someone provide me with code to do this, I hope to get back into learning VB one day.

Thanks,

BP

#2
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well you have to use the picture box object, and as for the code it depends on how you plan to open the image.

#3
blueparukia

blueparukia

    Newbie

  • Members
  • Pip
  • 3 posts
Well, press a comand button "Open" (cmd_open) and you jsut chose a file like in most programs when you open a file.


BP

#4
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
Just make a PictureBox and CommandButton object. Then put this code into Command1_Click()

Picture1.Picture = LoadPicture(app.path & "\picture.dgn")

I tested in VB6, works fine.

#5
blueparukia

blueparukia

    Newbie

  • Members
  • Pip
  • 3 posts
I did it with Common Dialog :)


Thanks for your help,

BP

#6
TheVbMaster

TheVbMaster

    Newbie

  • Members
  • Pip
  • 1 posts

blueparukia said:

Now, basically, I want to make a VB program that can recognise custom file types (not really custom, more on that later).

Basically, there are 2 crucial elements I am missing.

1. The ability to view images. Using Microsoft VB6, what type of object do I want to add for the images to display in, and what code do I need?

2. Reading a semi-custom file extension. Say I have renamed a file from: image.png to image.dgn for example. It is still a png image, but has a different name. So when you press cmd_open I need it to browse only for files that have the .dgn/.dgnet extension, and open them as .pngs.

I haven't used VB for 3 years now, and am VERY rusty. I can't even remember how to make a browser box to open files :confused:


Can someone provide me with code to do this, I hope to get back into learning VB one day.

Thanks,
BP

Make a Picture Box and a Text Box.

Add the code below.

Private Sub Form_Load()
Me.Caption = "Pic Viewer"
Text1.Text = "Enter Pic Here"
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyReturn
Picture1.Picture = VB.LoadPicture(Text1.Text)
End Select
End Sub

Hope this helped! :c-thumbup:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users