|
-
Jun 30th, 2004, 08:54 AM
#1
Thread Starter
Lively Member
Loading Multiple Forms
I Have a Small form (frmAddItemNumber) with a text box (txtAdditemNumber) and a command button(cmdAddItemNumber)
This is what I need the form to do.
1) Connect to the database (Complete)
2) Store the value entered into textbox to database. (Complete)
3) Load a blank form so the user can draw on it. Must be a different form for each value entered in the textbox. (Not Complete)
Any Ideas on how to do #3. Someone told me that I could use a hashtable but I could not get it to work.
Dim NewForm As New Form1
Dim MyHashTable As New Hashtable
MyHashTable.Add(1, NewForm)
Dim CurrentForm As frmAddItemNumber = MyHashTable(1)
CurrentForm.Show()
-
Jun 30th, 2004, 09:53 AM
#2
Frenzied Member
Your CurrentForm is a different type than the Form you put in the Hash Table. One is type Form1, the other is type frmAdditemNumber. The following code works fine:
Dim MyForm As New Form1
Dim ht As New Hashtable
Dim CurrentForm As Form1
ht.Add(1, MyForm)
CurrentForm = ht(1)
CurrentForm.Show()
And you can even leave out the CurrentForm and do:
Dim MyForm As New Form1
Dim ht As New Hashtable
ht.Add(1, MyForm)
ht(1).Show()
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 30th, 2004, 10:04 AM
#3
Thread Starter
Lively Member
It works!! I am new at VB.Net. What is the best source of information to learn vb.net. Books, internet sites? If so, what books or sites are the best.
Thanks for your help!!!!!!!!!!!!!!!!!
-
Jun 30th, 2004, 10:08 AM
#4
Thread Starter
Lively Member
The only thing wrong with the way my program runs right now is that I need to bring up new forms every time the add button is clicked on. Right now we have it set up to bring up form1. Is thier a way to create new forms each time?
-
Jun 30th, 2004, 10:17 AM
#5
Frenzied Member
You could change the type to just Form, but if I am remembering correctly you had some draw functions as part of your Form1. Why not create a new blank form that just has the draw functions you need and make that the type that you new and add to the Hashtable?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 30th, 2004, 10:30 AM
#6
Thread Starter
Lively Member
Well i am using my draw form instead of form1. so when the additemnumber button is seleted the draw form loads up. So now when I draw on the form I need to be able to save it to the database so I can retrieve it later. Is this posible?
-
Jun 30th, 2004, 10:49 AM
#7
Frenzied Member
Look into object Serialization.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 30th, 2004, 11:35 AM
#8
Thread Starter
Lively Member
What does this line of code mean
ht.Add(1, MyForm)
-
Jun 30th, 2004, 11:47 AM
#9
Frenzied Member
You are adding an object called MyForm to the hashtable collection keyed to 1.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 30th, 2004, 12:09 PM
#10
Thread Starter
Lively Member
I have a book that talks about serializable but ties it with xml. Saving it to a file. Do you know where I kind find info on using vb.net with an sql database?
-
Jun 30th, 2004, 01:00 PM
#11
Frenzied Member
I can't say that I've played around with it too much. I would guess though that you could serialize your forms into a MemoryStream, and then use a BinaryReader to read data from that stream and write it to, for example, an image field in a SQL Server database. I've never tried to do it though, so that is just a thought of a possible approach. Maybe somebody here has done it and knows better.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|