nate-d-o-double-g

i keep getting compile errors with this code but why

pb.Image = ImageList1.Images(0)
Label1.Text = "Gettin ready for the ball...pretty isn't she! "
If pb.Image Is ImageList1.Images(0) Then
pb.Image = ImageList1.Images(1)
Label1.Text = "Bad Gyal forward!"
ElseIf pb.Image Is ImageList1.Images(1) Then
pb.Image = ImageList1.Images(2)
Label1.Text = "Nathan's fave..."
ElseIf pb.Image Is ImageList1.Images(2) Then
pb.Image = ImageList1.Images(3)
ElseIf pb.Image Is ImageList1.Images(3) Then
MsgBox("This boi luvs u girl!.x.x.x.")
Else
Label1.Text = ""
End If

ive tried everything including with no imagelist:

If pb.Image Is Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\Gettin' Ready 4 the Ball.jpg") Then
pb.Image = Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\Gettin' Ready 4 the Ball.jpg")
Label1.Text = "Gettin ready for the ball...pretty isn't she! "
ElseIf pb.Image Is Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\Gettin' Ready 4 the Ball.jpg") Then
pb.Image = Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\DSC00583.JPG")
Label1.Text = "Bad Gyal forward!"
ElseIf pb.Image Is Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\DSC00583.JPG") Then
pb.Image = Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\Me 3.JPG")
Label1.Text = "Nathan's fave..."
ElseIf pb.Image Is Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\Me 3.JPG") Then
pb.Image = Image.FromFile("C:\Documents and Settings\Nathan II\My Documents\My Received Files\Me 3.JPG")
Label1.Text = "And she's good at hairdressing too!x"
MsgBox("Nathan luvs u girl!...")
End If

am i missing anything




Re: Visual Basic Express Edition why imagelist errors with this?

nobugz

You need to tell us what statement generates the error and what the error message is. Your second version cannot work, the "Is" operator will always evaluate to false. Forced to guess: you got a problem with "pb". You used default names on all the other controls (Label1, ImageList1), the default name for a picturebox would be PictureBox1, not "pb".





Re: Visual Basic Express Edition why imagelist errors with this?

Tall Dude

The picturebox, once it receives the bytes that make up

a picture, from whatever source, retains no information

about where the image came from (filename or imagelist index.)

You have to implement a different logic yourself to keep track

of what picture is currently in the picturebox.






Re: Visual Basic Express Edition why imagelist errors with this?

nate-d-o-double-g

Ok, ignore the previous problem before as I have now revised it, but now

I have another shortfall. This code:

Imports System.Drawing.Image

Imports System.Resources

Public Class Form1

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

If ComboBox1.Text = "" Then

MsgBox("Choose a time interval n the combobox", MsgBoxStyle.Exclamation)

Exit Sub

End If

MsgBox("A little slideshow...xx")

Timer1.Interval = 1000

Timer1.Enabled = True

End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

Me.Height = PictureBox1.Height + 20

Me.Width = PictureBox1.Width + 20

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Timer1.Enabled = False

PictureBox1.Image = Nothing

Label1.Text = ""

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Try

Timer1.Interval = Integer.Parse(ComboBox1.Text)

If PictureBox1.Image Is Nothing Then

PictureBox1.Image = My.Resources.ball

Label1.Text = "Gettin ready for the ball...pretty isn't she! "

Exit Sub

ElseIf PictureBox1.Image Is My.Resources.Ball Then

PictureBox1.Image = My.Resources.methink

Label1.Text = "Bad Gyal forward!"

Exit Sub

ElseIf PictureBox1.Image Is My.Resources.methink Then

PictureBox1.Image = My.Resources.mefave

Label1.Text = "Nathan's fave..."

Exit Sub

ElseIf PictureBox1.Image Is My.Resources.mefave Then

PictureBox1.Image = My.Resources.hair

Label1.Text = "And she's good at hairdressing too!x"

MsgBox("Nathan luvs u girl!.x.x.x.")

Dialog1.Show()

Timer1.Enabled = False

Exit Sub

End If

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

With ComboBox1.Items

For i As Int32 = 1000 To 100000 Step 100

.Add(i)

Next

End With

End Sub

Private Sub PictureBox1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Resize

Me.Height = PictureBox1.Image.Height + 20

Me.Width = PictureBox1.Image.Width + 20

End Sub

End Class

...when I try to debug it, it claims that it has building success, but the actual program window won't appear

and gives the following exception:

System.InvalidOperationException was unhandled
Message="An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."
Source="Angie"
StackTrace:
at Angie.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at Angie.My.MyProject.MyForms.get_Form1()
at Angie.My.MyApplication.OnCreateMainForm() in C:\Documents and Settings\Nathan II\Local Settings\Application Data\Temporary Projects\Angie\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Angie.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

...so...any ideas as to what's going on






Re: Visual Basic Express Edition why imagelist errors with this?

nobugz

It bombs on the designer generated code (Form1.Designer.vb) that you didn't post. The actual exception is contained in the exception's InnerException which you didn't post.





Re: Visual Basic Express Edition why imagelist errors with this?

nate-d-o-double-g

'------------------------------------------------------------------------------

' <auto-generated>

' This code was generated by a tool.

' Runtime Version:2.0.50727.42

'

' Changes to this file may cause incorrect behavior and will be lost if

' the code is regenerated.

' </auto-generated>

'------------------------------------------------------------------------------

Option Strict On

Option Explicit On

Namespace My

'NOTE: This file is auto-generated; do not modify it directly. To make changes,

' or if you encounter build errors in this file, go to the Project Designer

' (go to Project Properties or double-click the My Project node in

' Solution Explorer), and make changes on the Application tab.

'

Partial Friend Class MyApplication

<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _

Public Sub New()

MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)

Me.IsSingleInstance = false

Me.EnableVisualStyles = true

Me.SaveMySettingsOnExit = true

Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses

End Sub

<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _

Protected Overrides Sub OnCreateMainForm()

Me.MainForm = Global.Angie.Form1

End Sub

End Class

End Namespace