|
My ID is 426red@gmail.com
|
|
|
|
|
Hi,
We have a number of VB6 applications and would like to start converting them to VB.NET. We also have some VB.NET applications and we do not quite understand the way the forms and controls on those behave.
In VB6 we might have 4 forms. Each form has controls and code. Let us use a Date Picker as an example. Assume Form2 has dtpStart on it.
The VB6 program starts with Sub Main then shows frmMain.
frmMain loads the other forms. Each form load does housekeeping.
Code in OTHER forms / modules may reference the dtpStart on Form2. And this all works fine.
If VB.Net the behavior seems to be totally different.
Usage of the dtpStart gets errors. It is also unclear if .text or .value should be used and when (we get errors on both).
Is there a good explanation of the different behaviors someplace?
Or can someone out there be willing to answer some direct questions on this.
THanks
Jack
|
|
|
|
|
You should use the value property as in (value = datetime type):
dateTimePicker1.Value = DateTime.Now.AddDays(10)
You should probably use properties to modify control values from form to form vs. accessing the controls directly.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Don't know much about VB6. In .Net, scope identifiers determine places from where you can access an object. For example, a public object can be accessed from anywhere in the application while a private can be accessed only within the class it is declared. If you need to access the control properties from other form, use properties or delegate(if you need to perform some action).
There is a difference between text and value property. Text will get the date in the format it is shown in the control as a string. Value would give you the date value regardless of the format it is displayed in the control.
|
|
|
|
|
One of the biggest differences with forms is that VB6 used a default shared instance of each form. VB.Net does not do that by default (although the upgrade wizard does create these instances when moving from VB6 to .NET). That is why you can't say Form2.dtpStart in .NET.
As far as the property, I would try to find out which property on the DateTimePicker is the default property in VB6 (another thing that doesn't come up to .NET) and then use the equivalent property (the value property seems more likely to be what you want). Also, you will need to make sure that you pass the correct data type into the property (a Date for the Value property of a DateTimePicker).
|
|
|
|
|
HI CP ,
Location : Areas, Countries , Capitals
Item List : property selected in Location and load items in Item List
I am having 1 property with drop down : Areas, Countries , Capitals
suppose if i select the Areas then i have to load dynamically Areas thru the .txt file
and if i clicked countries then i have to load dynamically
and the same .
How can i do this Dynamically ?? while clicking the particular item .
Regards,
|
|
|
|
|
If I'm following you correctly, each combo is dependent off another. I'm assuming you have some kind of a settings class (with related classes for the combo(s)?) that the property grid is set to.
You could in the settings class, for each property set statement, parse the text files and update the values for the other properties as needed, which would update the values in the combo(s).
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi CP
This is my code i am retrieving a property value which raises the error
Public Class cTxtBoxProperties
<Category("Misc")> <Description("Displays the type of data associated with the control")> _
<TypeConverter(GetType(MyDataType))> _
Public Property DataType()
Get
Return _DataType
End Get
Set(ByVal value As Object)
_DataType = value
End Set
End Property
<Category("Misc")> <TypeConverter(GetType(NumberFormats))> _
<Description("Displays the format of the control")> _
Public Property Format() As String
Get
Return _Format
End Get
Set(ByVal value As String)
_Format = value
End Set
End Property
End Class
Dim tPropertyName As String = "DataType"
Dim objTxt As Type = GetType(cTextBoxProperties)
Dim PiInfo As PropertyInfo = objTxt.GetType.GetProperty("DataType")
Dim ObjPropertyValue As Object = PiInfo.GetValue(objTxt, Nothing)
Public Class NumberFormats : Inherits System.ComponentModel.StringConverter
Dim alist As New ArrayList
Dim ControlNames() As String
Public Overloads Overrides Function GetStandardValues(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection
alist = New ArrayList
alist = GetNumberFormats()
ControlNames = CType(alist.ToArray(GetType(System.String)), String())
Return New StandardValuesCollection(ControlNames)
End Function
Public Overloads Overrides Function GetStandardValuesSupported(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean
Return True
End Function
Public Overloads Overrides Function GetStandardValuesExclusive(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean
Return True
End Function
Protected Friend Function GetNumberFormats() As ArrayList
GetNumberFormats = Nothing
Dim objFStream As FileStream = Nothing
Dim objReader As StreamReader = Nothing
Dim fiInfo As FileInfo = Nothing
Dim tFontSizeFilePath As String = ""
Dim tNumberFormats() As String
Dim alist As New ArrayList
Dim CTextbox As cTextBoxProperties = Nothing
Dim tFileName As String = ""
Try
'' Here Raising the ERROR
Dim tPropertyName As String = "DataType"
Dim objTxt As Type = GetType(cTxtBoxProperties)
Dim PiInfo As PropertyInfo = objTxt.GetType.GetProperty("DataType")
Dim ObjPropertyValue As Object = PiInfo.GetValue(objTxt, Nothing)
<b>'' Here Raising the ERROR </b>
tFontSizeFilePath = String.Concat(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, tFileName)
fiInfo = New FileInfo(tFontSizeFilePath)
If fiInfo.Exists Then
objFStream = New FileStream(tFontSizeFilePath, FileMode.OpenOrCreate, FileAccess.Read)
objReader = New StreamReader(objFStream)
While objReader.Peek <> -1
alist.Add(objReader.ReadLine.ToString.Trim)
End While
objReader.Close()
objFStream.Close()
Return alist
Else
MsgBox(tFileName & "is not existed in Application Path.")
Exit Try
End If
Catch ex As Exception
MsgBox("GetNumberFormats : " & Err.Description, MsgBoxStyle.Critical)
Finally
If Not fiInfo Is Nothing Then fiInfo = Nothing
If Not objFStream Is Nothing Then objFStream = Nothing
If Not objReader Is Nothing Then objReader = Nothing
If Not CTextbox Is Nothing Then CTextbox = Nothing
Erase tNumberFormats
End Try
End Function
End Class
Regards
|
|
|
|
|
how can I include solid works 3D images in my vb.net project which have extensions of sldprt,Is there any chance to do so through vb.net only or some think components to included in to that?
|
|
|
|
|
You'd be better off looking at the company's site to see if you can tie into their .dlls/apis.
Some links I found from Google:
http://www.solidworks.com/sw/support/1835_ENU_HTML.htm
http://www.cadsolutions.ca/magazine/api.asp
http://lmgtfy.com/?q=solidworks+api
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi,
I'm currently working on a 2D game engine for my RPG. Now the work on the physics engine is almost done, but the graphics are seems to be the biggest problem. I'm using VB 2008 and for the graphics - GDI+ . Almost all of the objects in my game are *png images, with smooth shadows and so on... I'm drawing the objects using two methods: the first one sets the drawing priority so that no one player can step on the head of other players. The second one is the loop that draws all the objects(players and textures) on the playground, that loop uses the GDI+ Graphics.DrawImage function and all this code looks like this:
'this subroutine sets the draw priority:
Sub SetObjDrawPriority()
For i = 0 To UBound(HBD)
Select Case HBD(i).booIsAlive
Case True
intDrawPriority(i) = HBD(i).intTop
End Select
Next
Array.Sort(intDrawPriority)
End Sub
Sub DrawAllObjects(ByVal e As System.Windows.Forms.PaintEventArgs)
Try
SetObjDrawPriority()
For i = 0 To UBound(HBD)
For i2 = 0 To UBound(HBD)
If HBD(i2).intTop = intDrawPriority(i) Then
e.Graphics.DrawImage(HBD(i2).bmpFace, HBD(i2).intLeft, _
HBD(i2).intDrawTop, HBD(i2).intWidth, HBD(i2).intObjDrawHeight)
End If
Next
Next
Catch ex As Exception
End Try
End Sub
If I use *bmp texture for the objects with this size: 51 x 86 I can move simultaneously more than 200 objects on the visible area of the screen which is great, but If I replace the *bmp with *png images(with the same size: 51 x 86) the performance goes so bad that I can move normally less than 40 objects! Please tell me whats wrong. Is there any problem with the GDI+? I heard that GDI+ is wery slow and most of the programmers avoid it. I think that the code is pretty simple, but anyway maybe I'm wrong, please tell me how to optimize the code in case to get better performance.
Thank you.
|
|
|
|
|
Maybe because png pic´s are compressed?
|
|
|
|
|
PNG's are compressed images. They have to be uncompressed to draw them. If you're requiring that kind of performance, look into the XNA Framework.
|
|
|
|
|
I've never heard before that PNG is compressed is there an uncompressed PNG format?
I'm currently learning C++ but I'm only on the beginning so I can't move that fast to XNA, cause as I know XNA requires C++ or C#.
|
|
|
|
|
O.G.I. wrote: I'm currently learning C++ but I'm only on the beginning so I can't move that fast to XNA, cause as I know XNA requires C++ or C#.
Nothing like trial by fire right? You could always give a try and post questions when you get stuck.
Ping compression details
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi,
I don't see where the image's fileformat would be relevant, assuming you load the images into memory once (hence outside your drawing methods), which turns them into uncompressed bitmaps anyway, e.g. using Bitmap bm=Bitmap.FromFile(filepath); or something similar with FromSream. (example is C# syntax!).
PS: I strongly object to your code swallowing exceptions; if you (think you) need a try-catch, then do something useful with the exception, e.g. display it's Exception.ToString().
[ADDED]And if there is a very specific exception that you rightfully want to ignore, add a catch for that specific exception and insert a comment as to why it is OK to ignore it; then leave the more general catch out, or put some code in it.
[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
modified on Thursday, June 25, 2009 10:44 AM
|
|
|
|
|
how can i fire a form through tree view node click event.
|
|
|
|
|
Create object of the form and use Show or ShowDialog method (as applicable).
|
|
|
|
|
thanks for u r replay my problem is in the tree node selction program
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim childnum, index As Int32
childnum = TreeView1.SelectedNode.GetNodeCount(False)
index = TreeView1.SelectedNode.Index
'index = index + 1
If index = 0 Then
Button2.Show()
GroupBox1.Show()
End If
End Sub
The Above function is not working for me to select tree node and fire,is there any thing wrong in tn my prg.
|
|
|
|
|
I'm not sure I'm completely following you here. The controls are displayed when the index is 1 right? What else are you expecting to occur?
Also, check that you have at least 2 nodes in the treeview since the index is zero based.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I tried the aabove code by making a button visable false and on selcting a perticular treenode it will appear but the same code is not working for the group box that consits of some group of buttons.
I want make that group box visable when i click on a perticular treeview node.
|
|
|
|
|
I tried the aabove code by making a button visable false and on selcting a perticular treenode it will appear but the same code is not working for the group box that consits of some group of buttons.
I want make that group box visable when i click on a perticular treeview node.One more thing i have i have 8 child nodes for my tree so thre is no problem of zero index base.
|
|
|
|
|
Your code looks like it should work. Check the visible property (should be true) on the button controls in the group box to see if visible = true. If not, you'll need to change that at design time or during run time looping the groupbox's control collection.
Quick test app you can do.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'add a group box and stuff with button controls
For Each ctl As Control In GroupBox1.Controls
ctl.Visible = True
Next
GroupBox1.Visible = False
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
If e.Node.Index = 5 Then
GroupBox1.Visible = True
End If
End Sub
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Thanks Jon_Boy Your code is working for me.
|
|
|
|
|
TreeViewEventArgs has all the properties you need. You can use them right away.
Apart from that what exactly is the problem you are facing.
|
|
|
|