Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Visual Basic Programming

Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-08-2008, 08:01 PM
dream dream is offline
Newbie
 
Join Date: May 2008
Posts: 7
Rep Power: 0
dream is on a distinguished road
Default Creating a Class in Visual Studios.Net (Visual Basic Section)

Hello, I am new to using Visual Studios.Net. I am trying to write a class using Visual Studios.Net in the Visual Basic section. Could someone tell me what I am doing wrong?

Module Module1

Public Class MyClassName

End Class
Sub New()
Dim intVariable As Integer
intVariable = 0

End Sub
Property Variable() As Integer
Get
Return Variable

End Get
Set(ByVal Value As Integer)
Variable = Value
End Set
End Property
MyClassName End Class
REM I don't really know if End MyClassName should be at the end.
REM book has End Class at the end.
REM But the programs still manages to run I think.
End Module
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-09-2008, 11:10 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,069
Last Blog:
Reading Jet Databases ...
Rep Power: 27
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

The End Class should not be at the top, but at the bottom with the REM statements. Incidentally, you can now use the ' character instead of REM to comment.

In VS using a module to write a class is a pointless way, when you can actually add your own class directly. To do this, go to Add New Item and choose Class. Give it a name, and accept. It should load up with code already set up. Simply add the methods to populate the class.
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-09-2008, 06:00 PM
dream dream is offline
Newbie
 
Join Date: May 2008
Posts: 7
Rep Power: 0
dream is on a distinguished road
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

Thanks for the help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-10-2008, 09:18 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,069
Last Blog:
Reading Jet Databases ...
Rep Power: 27
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

Is it working now?
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-10-2008, 10:26 PM
dream dream is offline
Newbie
 
Join Date: May 2008
Posts: 7
Rep Power: 0
dream is on a distinguished road
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

Yeah it is ok now. I am having problems activating my direct x controller though. I am reading a book called Gaming Programming for Teens. I believe that the author left out many important details about visual basic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 05-11-2008, 03:23 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,069
Last Blog:
Reading Jet Databases ...
Rep Power: 27
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

Oh - maybe it's more of a book for advanced VB users. Is your computer powerful enough for Direct X?
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-12-2008, 01:28 PM
dream dream is offline
Newbie
 
Join Date: May 2008
Posts: 7
Rep Power: 0
dream is on a distinguished road
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

Yeah it should be. I just installed a graphics card geforce 7200 series. I past the test to see if it is obsolete. But since I am new to VB I don't really know who to initialize a device yet for direct X. Mainly I am just trying to write some code to form a window and changes its color to blue. I believe it has something to do with the adapters of the device or something of that nature.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-12-2008, 01:32 PM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,069
Last Blog:
Reading Jet Databases ...
Rep Power: 27
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

You shouldn't need DirectX just to display a form! Use a simple Form object, and change its BackColor to Color.Blue, like so:
Code:
Dim f As New Form()
f.BackColor = Color.Blue
f.Show()
You can change any extra properties of the 'f' object before showing it, to make it look just the way you want it to.
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 05-12-2008, 01:41 PM
dream dream is offline
Newbie
 
Join Date: May 2008
Posts: 7
Rep Power: 0
dream is on a distinguished road
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

Quote:
Originally Posted by Xav View Post
You shouldn't need DirectX just to display a form! Use a simple Form object, and change its BackColor to Color.Blue, like so:
Code:
Dim f As New Form()
f.BackColor = Color.Blue
f.Show()
You can change any extra properties of the 'f' object before showing it, to make it look just the way you want it to.
It is that simple? Here is the command line that I am having problems with below:

REM Create the Direct3D device
device = New Direct3D.Device(adapterNumber, Direct3D.DeviceType.Hardware, Me, flags, params)


Here is the program below:

Imports Microsoft.DirectX

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region
Dim device As Microsoft.DirectX.Direct3D.Device

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Size = New Size(800, 600)
Me.Text = "DirectX Initialization Demo"
Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True)
REM the above statements resize the window of the form

REM set up the presentation parameters
Dim params As New Direct3D.PresentParameters
params.Windowed = True
params.SwapEffect = Direct3D.SwapEffect.Discard
params.AutoDepthStencilFormat = Direct3D.DepthFormat.D16
params.EnableAutoDepthStencil = True
params.BackBufferCount = 1
params.BackBufferCount = 800
params.BackBufferCount = 600

REM Check video card capabilities
Dim adapterNumber As Integer = Direct3D.Manager.Adapters.Default.Adapter
Dim flags As Direct3D.CreateFlags
flags = Direct3D.CreateFlags.HardwareVertexProcessing
flags += Direct3D.CreateFlags.PureDevice

Dim caps As Direct3D.Caps
caps = Direct3D.Manager.GetDeviceCaps(adapterNumber, Direct3D.DeviceType.Hardware)
If caps.DeviceCaps.SupportsHardwareTransformAndLight = False Or caps.DeviceCaps.SupportsPureDevice = False Then

MessageBox.Show("Your video card is obsolete.", "Hardware Problem")
End

End If

REM Create the Direct3D device
device = New Direct3D.Device(adapterNumber, Direct3D.DeviceType.Hardware, Me, flags, params)

End Sub

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
device.Clear(Direct3D.ClearFlags.Target + Direct3D.ClearFlags.ZBuffer, Color.Blue, 1.0, 0)
device.BeginScene()
device.EndScene()
device.Present()
Me.Invalidate()
End Sub
End Class

It is suppose to bring up a window and make the window blue.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 05-12-2008, 01:48 PM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,069
Last Blog:
Reading Jet Databases ...
Rep Power: 27
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: Creating a Class in Visual Studios.Net (Visual Basic Section)

BLIMEY! Oh, I see. I have just remembered you are writing games. Just displaying a blue window is easy using the standard .NET functions, but once you start writing complex games, there will be a point where this long code will overtake the normal .NET ones in terms of usability.

You see, the usual .NET framework is not designed to write games. This code might seem like a lot, but the more you try to draw to the screen, the easier it will seem.

If you want to use the standard .NET commands, you can install the XNA Game Library. This provides an extra set of tools for writing games, but your DirectX thingy looks fine, and I advise you to stick with the code it gives you - my example could not in a million years write a game!
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Starting C# with C# 2008 Express Edition Jordan CSharp Tutorials 13 06-06-2008 10:56 AM
PHP 5 and OOP Jordan PHP Tutorials 0 04-04-2008 05:06 PM
Visual Studio 2008: C# Hello World Tutorial Jordan CSharp Tutorials 1 02-27-2008 07:48 AM
Creating an image viewer in Visual Basic blueparukia Visual Basic Programming 4 09-10-2007 02:00 AM


All times are GMT -5. The time now is 01:26 AM.

Contest Stats

dargueta ........ 93.00000
John ........ 87.50000
Xav ........ 70.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads