Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 22nd, 2005, 6:24 PM   #1
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
vb6 to vb.net

alright i created an application in vb6 and when transferring it to vb.net it doesn't work. apparently it doesn't like the load function...

Error 1 'Public Event Load(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\Documents and Settings\Owner.HOME\My Documents\CS220\mp07\Project1.NET\MDIForm1.vb 9 3 mp07

Error 2 'Public Event Load(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\Documents and Settings\Owner.HOME\My Documents\CS220\mp07\Project1.NET\mp07.vb 137 3 mp07

Error 3 'Value' is not a member of 'System.Windows.Forms.Button'. C:\Documents and Settings\Owner.HOME\My Documents\CS220\mp07\Project1.NET\mp07.vb 148 6 mp07

here's the code...


mdiform1

Option Strict Off
Option Explicit On
Friend Class MDIForm1
	Inherits System.Windows.Forms.Form
	
	Private Sub MDIForm1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		
		'UPGRADE_ISSUE: Load statement is not supported. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="B530EFF2-3132-48F8-B8BC-D88AF543D321"'
		Load(Form1)
		
	End Sub
End Class

m07(form1 essentially)

Option Strict Off
Option Explicit On
Friend Class Form1
	Inherits System.Windows.Forms.Form
	'whack-a-gopher 1.0
	'2005 benjamin hancock
	'assaignment mp07 for class CS220
	
	'there is so much more i could do with this...
	'-add sound, have a crosshair mouse pointer,
	'-add an intro window
	'-i've learned a lot from doing this project
	'-and have really enjoyed it
	
	
	'global variables
	Dim score As Short
	Dim randomNumber As Short
	Dim l4cap As Short
	
	
	'disable all the command buttons
	'-when program is initially loaded
	Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Dim x As Short
		Dim y As Short
		While (x < 25)
			c1(y).Enabled = False
			x = x + 1
			y = y + 1
		End While
		'end code
	End Sub
	
	
	Public Sub start_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles start.Click
		
		'change caption back to initial value
		Label3.Text = "WHACK-A-GOPHER!!!"
		
		'start all timers
		Timer1.Enabled = True
		Timer2.Enabled = True
		Timer3.Enabled = True
		
		'set timer3 variable
		l4cap = 30
		
		'set initial countdown time to 30
		Label4.Text = CStr(30)
		
		'enable all command buttons
		Dim x As Short
		Dim y As Short
		While (x < 25)
			c1(y).Enabled = True
			x = x + 1
			y = y + 1
		End While
		'end code
		
	End Sub
	
	Public Sub reset_Renamed_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles reset_Renamed.Click
		
		'change caption back to initial value
		Label3.Text = "WHACK-A-GOPHER!!!"
		
		'"turn off" the gameplay
		
		score = 0
		Label1.Text = CStr(score)
		Timer1.Enabled = False
		Timer2.Enabled = False
		Timer3.Enabled = False
		
		'change all the commandbuttons to their start picture
		Dim x As Short
		Dim y As Short
		x = 0
		y = 0
		
		While (x < 25)
			c1(y).Image = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\smallBlank.gif")
			x = x + 1
			y = y + 1
		End While
		'end code
		
		'disable all command buttons
		Dim x1 As Short
		Dim y1 As Short
		x1 = 0
		y1 = 0
		While (x1 < 25)
			c1(y1).Enabled = False
			x1 = x1 + 1
			y1 = y1 + 1
		End While
		'end code
		
	End Sub
	
	'end program
	Public Sub exit1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles exit1.Click
		End
	End Sub
	
	'set difficulty to easy
	Public Sub easy_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles easy.Click
		Dim Index As Short = easy.GetIndex(eventSender)
		Timer1.Interval = 1000
	End Sub
	
	'see above
	Public Sub normal_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles normal.Click
		Dim Index As Short = normal.GetIndex(eventSender)
		Timer1.Interval = 750
	End Sub
	
	'see above
	Public Sub hard_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles hard.Click
		Dim Index As Short = hard.GetIndex(eventSender)
		Timer1.Interval = 550
	End Sub
	
	'see above
	Public Sub asinine_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles asinine.Click
		Timer1.Interval = 100
	End Sub
	
	'display form with rules
	Public Sub rules_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles rules.Click
		Dim Index As Short = rules.GetIndex(eventSender)
		
		'UPGRADE_ISSUE: Load statement is not supported. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="B530EFF2-3132-48F8-B8BC-D88AF543D321"'
		Load(Form2)
		
	End Sub
	
	'here's where the fun starts...
	
	Private Sub c1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles c1.Click
		Dim Index As Short = c1.GetIndex(eventSender)
		
		'if you click on a gopher...
		'UPGRADE_ISSUE: CommandButton property c1.Item.Value was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
		If c1(randomNumber).Value Then
			
			'keep player from double-clicking on the gopher
			c1(randomNumber).Enabled = False
			
			'change command button to x'd-out gopher pic
			c1(randomNumber).Image = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\deadGopher.gif")
			
			'then give 'em some points!
			score = score + 25
			
			'show 'em their points so far
			Label1.Text = CStr(score)
			
		Else
			
			'if they click on a blank they lose ten points
			'(double-clicking on blanks is allowed)
			score = score - 10
			
			'show 'em their crappy score change
			Label1.Text = CStr(score)
			
		End If
		
	End Sub
	
	Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
		
		're-enable the last-clicked gopher button
		c1(randomNumber).Enabled = True
		
		'this code basically clears the buttons to blanks every second
		Dim x As Short
		Dim y As Short
		x = 0
		y = 0
		
		While (x < 25)
			c1(y).Image = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\smallBlank.gif")
			x = x + 1
			y = y + 1
		End While
		'end code
		
		'start generating a random number
		Call Randomize()
		
		'between 0 and 24
		randomNumber = Int(25 * Rnd())
		
		'assaign command button array element
		'-to the random number generated above
		'-and give it the gopher picture
		c1(randomNumber).Image = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\smallGopher.gif")
		
	End Sub
	
	Private Sub Timer2_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer2.Tick
		
		'stop the game
		Timer1.Enabled = False
		
		'display game-over dialogue
		Label3.Text = "GAME OVER"
		
		'turn off all the buttons again
		Dim x1 As Short
		Dim y1 As Short
		While (x1 < 25)
			c1(y1).Enabled = False
			x1 = x1 + 1
			y1 = y1 + 1
		End While
		'end code
		
	End Sub
	
	'this is just the code for the countdown timer
	'-in the lower right-hand corner
	'-so player is aware of their impending failure (or success)
	Private Sub Timer3_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer3.Tick
		If l4cap > 0 Then
			l4cap = CShort(Label4.Text)
			l4cap = l4cap - 1
			Label4.Text = CStr(l4cap)
		End If
		'end code
		
	End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub
End Class

form2

Option Explicit On
Friend Class Form2
	Inherits System.Windows.Forms.Form
	
	Public Sub back_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles back.Click
		
		Call Me.Close()
		
	End Sub

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

    End Sub
End Class

this is a project for school, works great and all under vb6.0...i got full credit and all of that, SO IT'S NOT FUCKING HOMEWORK AIIIIGHT!?! :p

just trying out my vb.net ide and would like to see it run under that, also i need to learn more about .NET. from the way the program converted my code, i'm guessing that vb.NET is quite a bit more "strongly typed". basically that load thing is all i care about, the value crap i can figure out myself.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 23rd, 2005, 7:35 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
The problem is that Load(Form1) is trying to load a class rather than an instance.
All forms in Vb.net are classes, and like in VB6 they need to be instantatiated in object variables to actually create a form.

Dim iForm1 as Form1 = New Form1
iForm.Show
Rory is offline   Reply With Quote
Old Sep 24th, 2005, 1:55 PM   #3
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
thanks, i'll try this later
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:59 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC