|
||||||
| Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 |
| Sponsored Links |
|
|
|
|||
|
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.
|
| Sponsored Links |
|
|
|
|||||
|
Oh - maybe it's more of a book for advanced VB users. Is your computer powerful enough for Direct X?
|
|
|||
|
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.
|
|
|||||
|
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() |
|
|||
|
Quote:
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. |
|
|||||
|
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! |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |