|
-
Aug 17th, 2002, 10:45 AM
#1
Thread Starter
Lively Member
1 more amazing question!!!
ok, to all the guys that read my last post on accessing a control out side of the form class, the solution is below, change it to what eva u want but the demo situation is as follows, 2 classes. one class is the form1 class the other class has one sub, the form also has a textbox, to get access to the textbox from the sub:
+public sub form1
+public class SMTP
-public sub SMTP
in the sub dim's just add this line(edit it first)
dim anynamehere as formnamewithcontol
now when you need it use the following, when you press the dot, u should have a fun menu appear, thenu can use .textbox1.text or what eva , hope this helps ppl
anynamehere.
LOL-==========================================
i almost forgot that i have a question to ask, GOMEN....
i have to save some settings but i dont think i want an ini file, i want an XML file like ppl have been talking about, i have seen then in some programs and they looks good and probibly easy to use, so how do i save stuf to an XML file and how do i get stuff back from aqn XML file tnx guys
TrAcER
-
Aug 17th, 2002, 12:30 PM
#2
PowerPoster
Go to the www.vb-world.com site. Then in the interaction menu, there is a codeback item. Click it.
Click on the C# section. I have submitted a way to save settings to the registry, and someone else has went behind me and modified my code to save settings to an xml file. If you can translate C# code to VB (shouldn't be that hard) then you will have it all.
-
Aug 17th, 2002, 01:31 PM
#3
Thread Starter
Lively Member
man, seems like im makeing a mountin out of a mole hill here, there must be an easyer way, im learning vb.net now and c# afterwards, so i dont think this is too good for me, anyone else have a tutorial or a code snipit already in vb Gomen.. but this seems like alot of work, i could take the easyway out and save to the registy but i dont wanna, thats not good practice
-
Aug 17th, 2002, 03:05 PM
#4
You can just load the xml file into a dataset and work with it and save it back to an xml file.
VB Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'read data from file
Dim ds As New DataSet()
'loda options xml file
ds.ReadXml(Application.StartupPath & "\test.xml")
Dim dr As DataRow
dr = ds.Tables("Options").Rows(0)
'put the options in local variables or whatever
'i just stacked them in a string since this is just a demo
'you could also just leave them in the dataset and use it as I have done here
Dim Opts As String
Opts = dr("Option1")
Opts &= ControlChars.NewLine & dr("Option2")
Opts &= ControlChars.NewLine & dr("Option3")
'show the result
MsgBox(Opts)
'write to file
dr("Option1") = "Item1"
dr("Option2") = True
dr("Option3") = 3.5
ds.WriteXml(Application.StartupPath & "\test.xml")
End Sub
And here is the xml file. Remember to put it in the bin folder or wherever the exe is.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<Options>
<Option1>Option1</Option1>
<Option2>Another Option</Option2>
<Option3>5.555</Option3>
</Options>
You could have different rows be different users and stuff like that as well.
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
|