|
You mean you want to create your own data store format for saving data to?
|
|
|
|
|
in Pascal we can to save data to ".dat" file, can I save in VB data in ".dat" format?
|
|
|
|
|
|
Now I understand your question and I believe someone else has pointed you in the right direction for a solution, but you do realize that now you will be responsible for full data access; meaning searching, updating, deleting ... With a database engine you can write your data access with SQL, with your custom solution you will have to write a custom finder, etc.
If it was me, I wouldn't do it. You can always try something like mySQL if you don't like MS-Access. Just my opinion.
Can you explain why you need to store your data in a custom .dat file and not some sort of database engine (or .mdb) ?
How many rows are we talking about ? 10, 100, 1,000 ... millions ?
Maybe you could store your data in an XML file.
Good luck.
|
|
|
|
|
I had the same question!!!!!!
|
|
|
|
|
for very small amounts of data i used sucessfully the ado recordset save / load method.
I cannot remember: What did I before google?
|
|
|
|
|
Let's say i have class called MyDialogClass.
This class uses a form with it's own set of custom properties and methods.
To declare one, you do this:
Dim MyDialogInstance As New MyDialogClass
How can i prevent my users from accessing the default properties that belongs with the form?
For example, users can change the backcolor of the form by typing this:
MyDialogInstance.BackColor = Color.Red
I don't want that. I only want the MyDialogInstance to show my custom properties and methods in the IntelliSense dropdown menu and omit all the default properties.
Virtual Space Shuttle Astronaut
|
|
|
|
|
Make it private. That would still mean that users can access the property, just makes it a bit harder; one would have to resort to reflection.
Bastard Programmer from Hell
|
|
|
|
|
Lol, you're Dutch too!
Anyway, just to make sure i understand, i need to change:
Public MyDialogClass
To:
Private MyDialogClass
VS2010 does'nt like it that way, it's whining about 'Types declared 'Private' must be inside another type'
Im not sure what that means, im quite new to writing my own classes.
Virtual Space Shuttle Astronaut
|
|
|
|
|
The Mighty Atom wrote: Lol, you're Dutch too!
Yup
The Mighty Atom wrote: Anyway, just to make sure i understand, i need to change
That makes the complete class "private"; you could do that if you wanted to hide the class entirely (hiding it in a public class, for example)
You'd want to hide a property, so you'll have to make that property private. That would look roughly like this;
Private Property SomeColor As Color
Get
Return Me._someColor
End Get
Set
Me._someColor = value
End Set
End Property
Now, if you try to look for the "BackColor" propery, then it won't be there in your class. I'm guessing that it's a property that's coming from a control that you're inheriting (Form is a control, and it has a backcolor) In that case, you could try to "overwrite" it by creating your own readonly-property that Shadows the inherited property, and hide it using attributes like BrowsableAttribute and EditorBrowsableAttribute . Here's a complete example project, inheriting from a panel, but works the same when inheriting from a form;
Public Class Form1
Private MyPanel As New MyPanelClass
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
MyPanel.Parent = Me
MyPanel.Dock = DockStyle.Fill
MsgBox(MyPanel.BackColor.ToString)
End Sub
End Class
Public Class MyPanelClass
Inherits Panel
<System.ComponentModel.BrowsableAttribute(False)> _
<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
Shadows ReadOnly Property BackColor
Get
Return Nothing
End Get
End Property
End Class
The new property effectively hides the old one that gets inherited from the Panel class. The BrowseAble attribute hides in the designer, the EditorBrowsable hides it from intellisense. It still compiles if you use the property (you can't cut remove it), but it's hidden and cannot be set anymore - and would only return "Nothing".
|
|
|
|
|
If depends on what you've done. I'll assume you just created your own dialog by inheriting from Form.
You cannot change the access level of the properties and methods by overriding them and it's just too much work to cover all of them anyway.
I'd probably hide the Dialog class you made by declaring the class as Friend instead of public, then create a wrapper class that creates it's own internal instance of your Dialog class. Expose only the methods and properties you want through the wrapper class. For example, when you need to show the dialog, that's going to be a method exposed by your wrapper class that calls the internal Dialogs ShowDialog method, waiting for it to return. Then the wrapper class just returns whatever ShowDialog returned.
|
|
|
|
|
What exactly is a wrapper? A class inside a class?
Are you willing to make an example for me with comments between the code?
Virtual Space Shuttle Astronaut
|
|
|
|
|
...sigh...
This would be your custom dialog form:
Friend Class MyDialogForm
Inherits Form
.
. yada, yada, yada
.
End Class
Public Class MyDialog
Implements IDisposable
' This keeps an instance of your dialog internal to
' this class, hiding EVERYTHING about it from the consumer.
Private _dialogForm As New MyDialogForm
' Now you just have to give the consumer exactly the things
' you want to expose.
Public Function ShowDialog() As DialogResult
Return _dialogForm.ShowDialog()
End Function
' You can expose any other properties you want. You can even
' use the internal form object as a backing field for your
' properties, where appropriate.
Public Property BackColor As Color
Get
Return _dialogForm.BackColor
End Get
Set(value as Color)
_dialogForm.BackColor = Value
End Set
End Property
' A form shown with ShowDialog has to be Disposed when you're
' done with it, so in the Dispose code, just look for the line
' that says "TODO: dispose managed state (managed objects)." and
' put this line under it:
_dialogForm.Dispose
End Class
To use the new dialog/wrapper, the consumer only has to create an instance of the wrapper class:
Dim d As New MyDialog
Dim result As DialogResult
result = d.ShowDialog()
|
|
|
|
|
+5, that's the cleaner and recommended solution
Bastard Programmer from Hell
|
|
|
|
|
I've caught myself overriding all the crap in a subclass before, then it dawned on me that this would be quicker to code and easier to debug when you don't have to wade through all the overrides.
|
|
|
|
|
Awesome, but i think im doing it wrong. I still have access to all the form properties, but my custom property named 'CustomProperty' isn't available.
Here's how my setup looks like:
[BaseDialogForm.vb]:
Friend Class BaseDialogForm
Form Designer code here, nothing else
End Class
[DialogForm.vb]:
Public Class DialogForm
Implements IDisposable
Private _dialogForm As New BaseDialogForm
Public Function ShowDialog() As DialogResult
Return _dialogForm.ShowDialog()
End Function
Public Property CustomProperty As String
Get
Return _dialogForm.Text
End Get
Set(ByVal value As String)
_dialogForm.Text = value
End Set
End Property
IDisposable Support code here
End Class
Virtual Space Shuttle Astronaut
|
|
|
|
|
Which one of these classes is your code creating an instance of?? From your description of the problem, it's the wrong one.
|
|
|
|
|
|
It's OK. it's not really YOUR code in those considering it's nothing but a copy'n'paste job, but it's OK.
|
|
|
|
|
Well of course it's copy'n'paste.
Anyway, looks like it's working the way i wanted.
Thanks, Dave.
Have some extra free Internets.
Virtual Space Shuttle Astronaut
|
|
|
|
|
I have a masked text box that displays a date dd/mm/yyyy e.g. 01/03/2007
When I try and change the format to read yyyy-mm-dd, it displays yyyy-mm-dd and not 2007-03-01
If it was any ordinary text box the syntax is format(MyDateField.Text, "yyyy-mm-dd") and it works.
It does not when the text box is masked. I must be doing something stupid or missing syntax.
How do I get a masked text box to format correctly as above?
|
|
|
|
|
Have a look at the datetimepicker control, could this handle your requirements better?
MSDN: Datetimepicker control[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
I have a datagridviewcombobox i want to after choosing an item to fill in the behind cell from a table in database im using datatable
Thanks for your help
|
|
|
|
|
I have a datagridviewcombobox i want to after choosing an item to fill in the behind cell from a table in database im using datatable
Thanks for your help
|
|
|
|
|
There is no reason to ask this twice.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|