|
For VB you can use console.writeline("""Welcome""")
|
|
|
|
|
|
I have a question. I need to know if it would be better for me to use a fill by method or a binding source.
Here is what I am doing.
I have a check box and 2 combo boxes for each day of the week. The user would check the Monday check box and then choose a time of day such as 6:00PM in the from time and 10:00PM in the to time combo box. Once the user selects the times the combo boxes populate these times from a database table and sets the selected value from another table that holds the time they selected.
Can you tell me what would be better to do? Should I use a FillBy Method or a Binding Source? When I first learned VB.Net in college about 2 years ago I just wrote a query and used a data adapter. I am new to VB.NET 2005 and have very little experience in VB.
When I added the () to (BindingSource) Dim instance As BindingSource() the instances are getting a blue squigly line. Why?
Here is the code I am writing using a Binding Source.
Dim bsMonStoreSched As BindingSource()<br />
Dim bsTuesStoreSched As BindingSource()<br />
Dim bsWedStoreSched As BindingSource()<br />
Dim bsThurStoreSched As BindingSource()<br />
Dim bsFriStoreSched As BindingSource()<br />
Dim bsSatStoreSched As BindingSource()<br />
Dim bsSunStoreSched As BindingSource()<br />
<br />
' create table adapter objects<br />
Dim hoursTableAdapter As New theLessonProgramDataSetTableAdapters.tbl_hoursTableAdapter<br />
Dim schedTableAdapter As New theLessonProgramDataSetTableAdapters.tbl_store_schedTableAdapter<br />
<br />
' create data set objects<br />
Dim lpDataSet As New theLessonProgramDataSet()<br />
<br />
' create dataTables<br />
Dim dtHours, dtSched As New DataTable()<br />
<br />
' create binding source<br />
Dim bsHours As BindingSource<br />
Dim bsStoreSched As BindingSource<br />
<br />
' fill the dataTables<br />
Try<br />
hoursTableAdapter.Fill(lpDataSet.tbl_hours)<br />
schedTableAdapter.Fill(lpDataSet.tbl_store_sched)<br />
Catch err As Exception<br />
MessageBox.Show(err.Message)<br />
End Try<br />
<br />
dtHours = lpDataSet.tbl_hours<br />
dtSched = lpDataSet.tbl_store_sched<br />
<br />
' Set the binding Source for mon - sun<br />
bsMonStoreSched.DataSource = dtSched<br />
bsTuesStoreSched.DataSource = dtSched<br />
bsWedStoreSched.DataSource = dtSched<br />
bsThurStoreSched.DataSource = dtSched<br />
bsFriStoreSched.DataSource = dtSched<br />
bsSatStoreSched.DataSource = dtSched<br />
bsSunStoreSched.DataSource = dtSched<br />
<br />
' Filter the items to show results.<br />
bsMonStoreSched.Filter = "ss_day = 'Monday'"<br />
bsTuesStoreSched.Filter = "ss_day = 'Tuesday'"<br />
bsWedStoreSched.Filter = "ss_day = 'Wednesday'"<br />
bsThurStoreSched.Filter = "ss_day = 'Thursday'"<br />
bsFriStoreSched.Filter = "ss_day = 'Friday'"<br />
bsSatStoreSched.Filter = "ss_day = 'Saturday'"<br />
bsSunStoreSched.Filter = "ss_day = 'Sunday'"<br />
<br />
' fill the Mon - Sun combo boxes with the hours<br />
cboLSMonFrom.DataSource = dtHours<br />
cboLSMonFrom.DisplayMember = "h_time"<br />
cboLSMonFrom.ValueMember = "h_id"<br />
cboLSTuesFrom.DataSource = dtHours<br />
cboLSTuesFrom.DisplayMember = "h_time"<br />
cboLSTuesFrom.ValueMember = "h_id"<br />
cboLSWedFrom.DataSource = dtHours<br />
cboLSWedFrom.DisplayMember = "h_time"<br />
cboLSWedFrom.ValueMember = "h_id"<br />
cboLSThurFrom.DataSource = dtHours<br />
cboLSThurFrom.DisplayMember = "h_time"<br />
cboLSThurFrom.ValueMember = "h_id"<br />
cboLSFriFrom.DataSource = dtHours<br />
cboLSFriFrom.DisplayMember = "h_time"<br />
cboLSFriFrom.ValueMember = "h_id"<br />
cboLSSatFrom.DataSource = dtHours<br />
cboLSSatFrom.DisplayMember = "h_time"<br />
cboLSSatFrom.ValueMember = "h_id"<br />
cboLSSunFrom.DataSource = dtHours<br />
cboLSSunFrom.DisplayMember = "h_time"<br />
cboLSSunFrom.ValueMember = "h_id"<br />
<br />
' bind the list controls selected value property<br />
cboLSMonFrom.DataBindings.Add("SelectedValue", bsMonStoreSched, "ss_id")<br />
cboLSTuesFrom.DataBindings.Add("SelectedValue", bsTuesStoreSched, "ss_id")<br />
cboLSWedFrom.DataBindings.Add("SelectedValue", bsWedStoreSched, "ss_id")<br />
cboLSThurFrom.DataBindings.Add("SelectedValue", bsThurStoreSched, "ss_id")<br />
cboLSFriFrom.DataBindings.Add("SelectedValue", bsFriStoreSched, "ss_id")<br />
cboLSSatFrom.DataBindings.Add("SelectedValue", bsSatStoreSched, "ss_id")<br />
cboLSSunFrom.DataBindings.Add("SelectedValue", bsSunStoreSched, "ss_id")
|
|
|
|
|
AAGTHosting wrote: Dim bsMonStoreSched As BindingSource()
Dim bsTuesStoreSched As BindingSource()
Dim bsWedStoreSched As BindingSource()
Dim bsThurStoreSched As BindingSource()
Dim bsFriStoreSched As BindingSource()
Dim bsSatStoreSched As BindingSource()
Dim bsSunStoreSched As BindingSource()
First, let me say that you have no reason to use this many bindingsources for what your code is suggesting you're doing. One is enough.
Second, seriously, pick up a book on VB.NET for beginners. These lines mearly declare a variable that CAN hold a BindingSource object. You never actually created any BindSource objects because you're missing the New keyword in the Dim statement.
Dim bsTuesStoreSched As New BindingSource()
The problem you run into with this code is that as soon as these variables fall out of scope, the BindingSources will be destroyed. You have to declare these in class scope, not method scope.
|
|
|
|
|
The word Greeting in gives me an error; " name is not declared" how can i solve it?
Private Sub DeliveryOptions_EnterEvent(ByVal sender As System.Object, ByVal e As AxVBVoiceLib._DGetdgEvents_EnterEvent) Handles DeliveryOptions.EnterEvent
'ByVal Greeting As Object
Greeting.RemoveAll()
Greeting.InsertIndexPhrase(0, FILE_LEAVE_VM_VAP, LV_VM_TO_SEND_MSG)
|
|
|
|
|
This means you don't have a variable called "Greeting" defined anywhere in scope.
Seriously, pick up a beginners book on VB.NET. This is a very basic error caused by not knowing how to declare variables.
|
|
|
|
|
Dave is right, you really need to get up to speed on your VB
First, you have you declaration of Greeting commented out. I guess that you did that because when you didn't the .RemoveAll() and InsertIndexPhrase() methods errored out. This is probably because those methods are not standard members of the Object type but rather members of some VBVoice object type.
|
|
|
|
|
Hello all!
When I call one of my dialogues with the ShowDialog() function my application exits. Just like that. No error message or anything. I have tried catching the error but it does not help. Also, this problem occurs only on some machines, all of which have no debugger installed. Unfortunately I have no idea where to start looking for the error. Does anybody know anything I can do short of writing the thing from scratch?
Happy new year!
Volker Weichert
|
|
|
|
|
If there's no error message, odds are, there's no error. One thing springs to mind - if you have a dialog with a button defined as being the OK button, and it launches a child with an OK button defned, pushing OK will close both.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank you for your answer.
In this case the parent form is a normal form. Also, I traced through the program and pinpointed the error to the actual ShowDialog() method. Since the dialog does not show but the application quits I guess there is an error somewhere. I just have no idea where to look for it .
Volker Weichert
|
|
|
|
|
I'm trying to write a method that loops through a form and dumps the name of all controls and the data from each control into a string, it works fine until it gets to a control that its self has controls in it, like a tabcontrol. Is there any work around so I can get this to work in a single method? The getValue(childControl) function simply uses a typeof check and returns the data of that control as a string. Any help would be appreciated.
Public Function reportApplicationState(ByVal controlList As Windows.Forms.Form.ControlCollection) As String<br />
Dim strIndent As String = ""<br />
Dim report As String = ""<br />
Dim childControl As Control<br />
For Each childControl In controlList<br />
If childControl.Controls.Count > 0 Then<br />
layoutIndent &= " "<br />
report &= childControl.Name & ControlChars.CrLf<br />
Dim nextChildControl As Control<br />
For Each nextChildControl In childControl.Controls<br />
reportApplicationState(nextChildControl.Controls)<br />
Next<br />
Else<br />
report &= layoutIndent & childControl.Name & getValue(childControl) & controlChars.CrLf<br />
End If<br />
Next<br />
Return report<br />
End Function
|
|
|
|
|
Additional info: reportApplicationState(nextChildControl.Controls) - throws exception
Exception thrown at runtime:
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'ControlCollection' to type 'ControlCollection'."
Source="detailedErrorReports"
StackTrace:
at detailedErrorReports.StateReport.reportApplicationState(ControlCollection controlList) in C:\Documents and Settings\Ed\My Documents\Visual Studio 2005\Projects\detailedErrorReports\detailedErrorReports\StateReport.vb:line 12
at detailedErrorReports.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Ed\My Documents\Visual Studio 2005\Projects\detailedErrorReports\detailedErrorReports\Form1.vb:line 5
sorry about the code sample indentation
|
|
|
|
|
I'd probably rewrite this so you don't have a "nextChildControl" section. One level should be enough.
Speaking of level, I'd also change this method to take as parameters a ControlCollection AND an interger representing depth, so you can have a collection in a collection in a collection, ... Probably something like this:
Public Function reportApplicationState(ByVal controlCollection As ControlCollection, Optional ByVal childDepth As Integer = 0) As String
Dim layoutIndent As New String(" "c, childDepth)
Dim report As String = String.Empty
Dim childControl As Control
For Each childControl In controlCollection
If childControl.Controls.Count > 0 Then
report &= childControl.Name & ":" & Environment.NewLine
report &= reportApplicationState(childControl.Controls, childDepth + 1)
Else
report &= layoutIndent & childControl.Name & getValue(childControl) & Environment.NewLine
End If
Next
Return report
End Function
This is by no means tested, but you should get the idea...
|
|
|
|
|
Your right in saying only one level is needed, the inner loop was only added after i initially had problems. This works fine for all controls on the controlList passed in, but when it calls its self when it finds a control with child controls i get an error casting from the child controls to a control list even though they appear to be of the same type. Any ideas on why the cast fails would be appreciated.
|
|
|
|
|
Hi Developers
I'm looking for an Open Source Invoice Management System, which I can modify easily according to my needs....
Please let me know if you know about any good resource about it. Thanks
|
|
|
|
|
|
Respected Dave
I googled first and then I posted here for help, anyways thanks for your HELP
|
|
|
|
|
Hi,
I'm building an app that will heavily use XML for inserting,searching,replacing,deleting...
I have solved most of the mechanics, but I didn't see a huge bug in my idea.
I need to insert xmlNodes or xml Elements in specified places in the file. Currently i'm using :
xmlNode = xmldocument.createElement("Element1")
xmlNode.setAttributes("Att1",Val1)
xmlDocument.documentElement.firstChild.FirstChild.appendChild(xmlNode)
etc...
The huge flaw of this is of course, as the file changes so the positions of many elements change so firstchild.firstchild becomes a totally different element over time as I do work on the file. So it is somewhere else like : childNodes(12).appendChild...
My question is: Is there a way to insert files using XPath or something like that where I could specifiy the name of the element or the relative path to it. like
xmlDocument.appendChild("//Category/System/[@ID=5]/SubRoutines/[@level=3]
something like that, well you get the idea.
Thanks a lot!
|
|
|
|
|
So you're looking to control the order of the children that show up under a node in the tree?? You can't control that. XML doesn't make any distictions about the order of child nodes common to one parent. Only that parent nodes must come before children.
You'd have to load all the current children into a collection, remove them from the XML document, then add them back to the parent node in the order you want them to appear.
|
|
|
|
|
I'm not sure if this is exactly what you are looking for, but I use an object of type System.Xml.XmlNodeList to reference xml nodes (I use VS2005, not sure if it's in other versions). The GetElementsByTagName will return a NodeList with all of the nodes that match the name. For example, this bit of code will set the variable strValue to the value of the first element in the file named "Element1":
Dim xDoc As New System.Xml.XmlDocument<br />
xDoc.Load("C:\MyFile.xml")<br />
<br />
Dim strValue as String = String.Empty<br />
<br />
Dim xList As System.Xml.XmlNodeList<br />
xList = xDoc.GetElementsByTagName("Element1")<br />
<br />
If xList.Count > 0 Then<br />
strValue = xList.Item(0).InnerText<br />
End If
Hope this at least helps point you in the right direction.
|
|
|
|
|
You could try to add a key attribute to the nodes that have to be sorted. Then write a class that implements IList and keeps its elements sorted after adding. That way you cannot sort the nodes in the xml file but have them sorted in your program. On the other hand, if you add another function that returns a sorted XmlNodeList you can insert the result of that in your XmlDocument and have a sorted list of childnodes in your file.
|
|
|
|
|
Hi Folks
I have this basic code.
Dim db As New MyLinqDataContext
Dim o As New Order
o.OrderName = "Cool Order"
db.Orders.InsertOnSubmit(o)
db.SubmitChanges()
db.Connection.Close()
(I originally have tried this on C#)
I have an orderid column which serves as a primary key which should update automatically when i insert the record.
When the code runs there is no record but the database is not updated. Anyone else having issues with this. Im using the express versions of visual studio 2008. thx in advance.
|
|
|
|
|
I am not very sure about this....
Is ur Database have auto commit option??? If not commit the transaction first
Good Luck
|
|
|
|
|
Hi all,
I want to save a webpage that contains tables into an excel file
using VB or VB.Net
thanks in advance
Priya
|
|
|
|
|
What's the question?? What part of this are you having problems with??
You can't save the table directly to Excel. You have to parse it out of the HTML data and put it into the cells you want, one cell at a time.
|
|
|
|