|
I guess, but I thought the 'pass a copy of the form to the constructor' solution was ugly enough
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I wasn't sure what to use for my project, thus i used 2 forms.
(My project)
In my main form, I choose a test. A new form(?) appears to allow the user to type some details about the test in a textbox. Then I can click a Save button, that is on the new form(?), to save the details.
I thought using a new form was ok, but if it is considered bad practice, any suggestions to what other ways are there? I have the SaveTest() method in my main form, but when I use frm1.SaveTest() on that Save button to call the method from my main form, I get that error. Hope what I'm saying makes sense
|
|
|
|
|
And I'm using Vb.Net..
This is my first graded project for Vb.Net as well, so yeah..i appreciate any help thanks!
|
|
|
|
|
Hi
Use ByRef instead of ByVal and pass the form which you want to call and then check out
|
|
|
|
|
Anonymous wrote:
I thought using a new form was ok
Of course it is, how else would you do it ?
Anonymous wrote:
if it is considered bad practice
No, passing one form to another is bad practice. Using a delegate to call one form from another is much nicer.
Anonymous wrote:
I have the SaveTest() method in my main form, but when I use frm1.SaveTest() on that Save button to call the method from my main form, I get that error
Because it's not the same Form1 that created Form2, it's an uninitialised form variable. Like I said.
Passing the same instance is a quick fix, setting up an event is much nicer, but a little more code. MSDN for delegates to get the idea.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Mark, have you considered the Rich Edit control? This accepts text in RTF format which may do what you want.
...Steve
|
|
|
|
|
Sorry my daughter deleted my 1st message.
|
|
|
|
|
I'm new to VB, but I'm trying to write a program where I can retrieve text from a text box after the program is shut down. I'm starting with SaveSettings, but it requires the "section" as a string from which I am wanting to save the text. What is a "section" so I might know what to type in.
I've seen a bazillion code examples of how to do this, but they all have been way over my head. It doesn't seem like it should be that complicated to do this?
|
|
|
|
|
Roofus01 wrote:
retrieve text from a text box after the program is shut down.
Uhhh...maybe I'm missing something here, but if the application is shutdown, the TextBox doesn't exist any more.
Are you saying that you want to save the strings in your textboxs so that you can retrieve them and fill in the textboxs again the next time the application is started?
The section name is any arbitrary name you want. You could call it TextBoxSettings for all it cares. It's just a name to help organize your settings, kind of like a folder.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes...basically, I want to be able to enter data in the textbox of my program, so when the program is started again, the information that I entered will appear again in the same textbox.
Does that make more sense? Thanks for your reply.
|
|
|
|
|
SaveSetting stores values in the Registry. The values you specify determine the location of the entry in the registry. The location translates to:
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\<AppName>\<Section>\<Key>
You can set the Section value to any you want to organize the values you save. The basic idea is that the combination of AppName, Section, and Key must be unique.
|
|
|
|
|
To see if I'm close here...I've got a "test" program I'm writing called "Save Data Test". The program has one text box and two buttons. One button is for saving the data and one is for loading the data back into the text box. The code I have for the save button is:
SaveSetting("Save Data Test", "Form1", "Textbox1", "Text")
The one for the load button is:
GetSetting("Save Data Test", "Form", "Textbox1", "Text")
Obviously I'm off here because it doesn't work, but am I close?
I do appreciate all the help.
|
|
|
|
|
Roofus01 wrote:
GetSetting("Save Data Test", "Form", "Textbox1", "Text")
If you're getting something, then you need to put it in a variable. You're close, but you need to store the result of GetSetting in a variable, then use that to specify your text.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
That makes sense, Christian. Thanks!
|
|
|
|
|
Dim MyText As String
MyText = Textbox1.Text
SaveSetting("Save Data Test", "Form1", "Textbox1", MyText)
.................
GetSetting("Save Data Test", "Form", "Textbox1", MyText)
Textbox1.Text = MyText
|
|
|
|
|
This is perfect! Thank you! I'll give it a try tomorrow in my application and I'll see if I can work it into the program I'm writing for my job.
|
|
|
|
|
Hi ,
The requirement is:
I have the following URL:
http://search.epilot.com/getresults.aspx?aff=test&ip=10.1.5.60&keyword=travel&source=s&r=w
This is a valid URL that returns results in XML format in IE.
How do I check if the URL will return response in XML format.
i.e. http://www.rediff.com willnot return response in xml format.
Is there any method by which we can validate a URL in this manner.
XML classes in .NET like XMLValidatingreader only check if an XML document is well formed.They donot validate URL strings.
Its very urgent.
Any tips on this would be very helpful
Thanx in Advance
|
|
|
|
|
Without actually downloading the document that the URL returns, there's no way to determine what the return document is going to be just by looking at the URL.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to check the difference between the time. If at this time it is 7.45pm and tomorrow 7.45pm it will be 24hrs. how can i make this?? By the way i am using vb.net
Adrian De Battista
|
|
|
|
|
Check out the intrinsic DateDiff function.
|
|
|
|
|
how to show the time only not the full date with time. I use TODAY.NOW.
Adrian De Battista
|
|
|
|
|
Check out the overloads of the .ToString() method. You can specify a format string that just has the parts of the date and time that you want to show.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
can i use the microsoft.vb.left(Today.now,11) with this way! or it is not good?? because right now i am using this method and i don't think so that it is 100% good.
|
|
|
|
|
I wouldn't. Then again, I wouldn't be using the code that came out of the conversion tool either. It's best to start from scratch and rewrite the project instead of trying to wrestle VB.NET into doing something "the old fashioned way".
Now() returns a DateTime object, not a string. The brief statement you posted wouldn't even compile. The Left method takes a string parameter, not a DateTime.
Dim currentTime As String = DateTime.Now().ToString("hh:mm:ss:")
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|