
absent
Avatar/Signature-
Posts
55 -
Joined
-
Last visited
About absent
- Birthday 01/22/1982
Personal Information
-
Occupation
Programmer
-
Visual Studio .NET Version
Visual Studio .NET 2003 Professional
-
.NET Preferred Language
VB6, .NET, HTML, JS, Java
absent's Achievements
Newbie (1/14)
0
Reputation
-
heya, Is there a way to "export" or save a treeview structure to file - Regardless of file format. The nodes are created dynamically based on user input. But now I need a way to save the nodes for multiple users. Cheers,
-
I'm not sure what to title this thread, so please bare with me... Is it possible to "insert" a cut down version of VB into an application written in VB.net? For eg MS Access, Word, Excel etc have VBA built into them or seeningly so... Regards,
-
erk... hmmmmmmmmmmmmmm there is that point also... I'm sort of still getting used to the more basic principles of VB.net - But know a bit moer on the advanced ones - Having been thrown in the deep end was both a good and bad thing... Cheers for the help m8
-
:confused: I have a small question relating to the old problem of passing variables between forms in vb.net. I think I might have found a way to do it but would like to know if it will work and if not why? Before the class declarations ie above the line Public Class Form2 Inherits System.Windows.Forms.Form If I insert 'Inserting this line Imports Project1.Form2 Public Class Form2 Inherits System.Windows.Forms.Form Will it not have the same effect as declaring the form "class" as an accesable object? By doing so I should be able to call the values from the different controls? Please bare in mind this is VB.net and not C#. Any feedback will be greatly appreciative...
-
Friend Sub BindToSQL() Dim i As Integer Dim node_letter As String trvClients.Nodes.Clear() 'Set document type trvClients.Nodes.Add("Client List") 'set documents trvClients.SelectedNode = trvClients.Nodes.Item(0) trvClients.ExpandAll() trvClients.ShowLines = True trvClients.ShowPlusMinus = True For i = 1 To 26 node_letter = Chr(64 + i) trvClients.SelectedNode.Nodes.Add(node_letter) Next 'Treeview Databinding Dim myrdr As SqlClient.SqlDataReader Dim node_key As String Dim entry_letter As String Dim node_name As String 'set_NewTree() SqlCommand1.Connection.Open() myrdr = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection) Do While myrdr.Read node_key = myrdr.GetString(1) entry_letter = Mid(myrdr.GetString(1), 1, 1) Dim MyNode As TreeNode i = 0 node_name = myrdr.GetString(1) & ", " & myrdr.GetString(2) For Each MyNode In trvClients.Nodes.Item(0).Nodes If MyNode.Text = entry_letter Then trvClients.Nodes.Item(0).Nodes.Item(MyNode.Index).Nodes.Add(node_name) End If Next Loop myrdr.Close() SqlConnection1.Close() End Sub
-
Right sorted it all out... I had to add 2 classes to achieve the desired result Public Class cWidget Public Name As String End Class and Public Class cWidgetCollection Inherits System.Collections.CollectionBase ' Visual Basic ' Creates a WidgetCollection object. 'Dim myWidgetCollection As New cWidgetCollection ' Restricts to Widget types, items that can be added to the collection. Public Sub Add(ByVal awidget As cWidget) ' Invokes Add method of the List object to add a widget. List.Add(awidget) End Sub Public Sub Remove(ByVal index As Integer) ' Check to see if there is a widget at the supplied index. If index > Count - 1 Or index < 0 Then ' If no widget exists, a messagebox is shown and the operation is ' cancelled. System.Windows.Forms.MessageBox.Show("Index not valid!") Else ' Invokes the RemoveAt method of the List object. List.RemoveAt(index) End If End Sub ' This line declares the Item property as ReadOnly, and ' declares that it will return a Widget object. Public ReadOnly Property Item(ByVal index As Integer) As cWidget Get ' The appropriate item is retrieved from the List object and ' explicitly cast to the Widget type, then returned to the ' caller. Return CType(List.Item(index), cWidget) End Get End Property End Class then in the button click event I put Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click Dim i As Integer For i = 0 To myWidgetCollection.Count - 1 If lstSelect.Text = myWidgetCollection.Item(i).Name Then MsgBox("Duplicate Record" & " " & myWidgetCollection.Item(i).Name _ , MsgBoxStyle.OKOnly, "Duplicate Record Detected") Exit Sub End If Next end sub It all works fine and can be used for form lifetime collections instead of single instance lifetimes.... If anyone has a comment or easier way to do this please let me know... Ta
-
Hey all! I know this might sound like something simple to do or easy to figure out, but it's been a long weekend - and the JD aint helping much... I have a dialog form that has got a SqlDataAdapter connecting controls on the form to a table in the SQL DB. The connections are loaded in the form load event as the user has to select settings etc from the dialog form. My problem is I have a button that closes the form when the user has completed selecting what ever they need to. I'm trying to pass those variables that were selected to a COMPLETELY new table in the database that is named according to the current date. Do I have to set the dataconnections to nothing and then reassign them to the new table and then do a update or would I have to have a class that stores the values and then pass them to a new dataconnection for the add/update? Thanx a million
-
Hey there... Is there a way to pass variables between forms? back in vb6 is was a matter of form1.text1.text = form2.text2.text when I try and do it now it does not work at all.... I'm using a SDI enviroment and am using a module to open and close my form programatically. ta
-
Fixed... I fixed the problem with it only adding one record at a time For Each dr In ds.Tables(0).Rows .Range("A" & i.ToString).Value = dr("LastName") .Range("B" & i.ToString).Value = dr("FirstName") .Range("C" & i.ToString).Value = dr("DateWorkComplete") .Range("D" & i.ToString).Value = dr("DetailsOfProblem") i += 1 Next should read i = i + 1 Next I am using an access db because that is what work is using for the record source - They still aint given me access to the SQL server yet... I'm only a temp here. I know I could pull the data str8 from access into excel, but the formatting of how the data is supposed to be layed out is not supported in Access. You mentioned making my select statement global? How would I go about that? I am trying to speed it up a bit, because there are huge amounts of data in the database as it is. And is there a way to kill the excel process when excel is closed down after the file is created > saved > closed? Thanx a million
-
I have a chunk of code that I wrote to export data from a access database table. It all works right until one small problem. It only extracts one record from the database and places it in Excel each time you click the button. There are 2 main chunks that are utilised to do this. I have isolated the problem to the ExtractData() sub. Could someone please assist me? All I want to do is pull all the records in the database to excel based on the Connectionstring. Private Sub PullData() lblMessage.Text = "" If (beginDate.Value <= endDate.Value) Then 'DECLARE VARIABLES Dim ds As New DataSet("DataSetName") Dim myConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Karen\Desktop\GetData\file.mdb;Persist Security Info=False") Dim myAdapter As New OleDb.OleDbDataAdapter Dim myCommand As New OleDb.OleDbCommand(("SELECT LastName, FirstName, Details, DateWorkComplete FROM CompletedAll WHERE DateWorkComplete Between #" + beginDate.Value.ToShortDateString() + "# And #" + endDate.Value.ToShortDateString() + "# ORDER BY DateWorkComplete"), myConnection) 'Open connection Try myConnection.Open() Catch ex As Exception lblMessage.Text = ex.Message myConnection.Close() End Try 'Bind myAdapter to myCommand myCommand.CommandType = CommandType.Text myAdapter.SelectCommand = myCommand myAdapter.SelectCommand.Connection = myConnection 'Bind myAdapter to dataset, then bind dataGrid to dataset Try myAdapter.Fill(ds) dataGrid.DataSource = ds Catch ex As Exception lblMessage.Text = ex.Message End Try 'Close connection myConnection.Close() Else lblMessage.Text = "Start date must be before end date" End If End Sub Private Sub ExtractData() lblMessage.Text = "" If (beginDate.Value <= endDate.Value) Then 'Initializes Excel and creates a new workbook/worksheet Dim excelApp As New Excel.Application Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add Dim excelWorksheet As Excel.Worksheet = _ CType(excelBook.Worksheets(1), Excel.Worksheet) 'Makes Excel invisible to the user until spreadsheet is populated excelApp.Visible = False With excelWorksheet 'Creates connections to pull data to DataSet Dim ds As New DataSet("DataSetName") Dim dr As DataRow Dim myConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Karen\Desktop\GetData\file.mdb;Persist Security Info=False") Dim myAdapter As New OleDb.OleDbDataAdapter Dim myCommand As New OleDb.OleDbCommand(("SELECT LastName, FirstName, Details, DateWorkComplete FROM CompletedAll WHERE DateWorkComplete Between #" + beginDate.Value.ToShortDateString() + "# And #" + endDate.Value.ToShortDateString() + "# ORDER BY DateWorkComplete"), myConnection) Dim i As Integer = 2 'Bind myAdapter to myCommand Try myCommand.CommandType = CommandType.Text myAdapter.SelectCommand = myCommand myAdapter.SelectCommand.Connection = myConnection myAdapter.Fill(ds) Catch ex As Exception lblMessage.Text = ex.Message End Try 'Format cell headings .Range("A1").Value = "Last Name" .Range("A1").Font.Bold = True .Range("A1").ColumnWidth = 15 .Range("B1").Value = "First Name" .Range("B1").Font.Bold = True .Range("B1").ColumnWidth = 15 .Range("C1").Value = "Date" .Range("C1").Font.Bold = True .Range("D1").Value = "Details" .Range("D1").Font.Bold = True .Range("D1").ColumnWidth = 150 'Populate Excel spreadsheet Try For Each dr In ds.Tables(0).Rows .Range("A" & i.ToString).Value = dr("LastName") .Range("B" & i.ToString).Value = dr("FirstName") .Range("C" & i.ToString).Value = dr("DateWorkComplete") .Range("D" & i.ToString).Value = dr("DetailsOfProblem") i += 1 Next Catch ex As Exception lblMessage.Text = ex.Message End Try 'Make Excel visible excelApp.Visible = True End With Else lblMessage.Text = "Start date must be before end date" End If End Sub Thanks a mil in advance.
-
not quite.... I'm using the ListDirectory class of the ObjectCollections... Anyone have an idea of how to use them as a string storage by using variables? I have got the varialbes stored in a container called "cache" if the value is not present in the cache then it is added to the cache and added to a list box. If the value is already present in the cache then a msgbox pops up with a duplication error. Is there a problem with my code? Or is my logic a little warped at the moment? ta in advance
-
Hey all... I'm trying to use an object collection to try and compare variables in a listbox... The thing is when a button is clicked and the variable in the 1st listbox is seen as a duplicate no matter if there is the same value present or not... Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click Dim cache As New ListDictionary ' Over here, the code to detect a click. Then... If Not cache.Contains(lstSelected.SelectedIndex) Then cache.Add(lstSelected.SelectedIndex, "") ' Note that the value is irrelevant...we're only interested in the key. Else Throw New Exception ' Do whatever to handle this. End If ' Carry on with whatever... Try 'FoundMatch() If Not cache.Contains(lstSelected.SelectedIndex) Then 'MsgBox("Duplicate Entry", MsgBoxStyle.OKOnly, "Duplication Error") lstSelected.Items.Add(lstSelect.Text) lstSelect.Items.Remove(lstSelect.Text) ElseIf cache.Contains(lstSelected.SelectedIndex) Then 'lstSelected.Items.Add(lstSelect.Text) 'lstSelect.Items.Remove(lstSelect.Text) MsgBox("Duplicate Entry", MsgBoxStyle.OKOnly, "Duplication Error") End If Catch ex As Exception MsgBox("Error Type : " & Err.Description, MsgBoxStyle.Exclamation, "Error Number : " & Err.Number) End Try End Sub Even if I comment/uncomment the values in the if block it still does not accept a value - Even if it is not present in the listbox... Any ideas where I am going wrong? or another way of achieving my goal?
-
ummmmmmmmm I am using a module to "open" and close" my forms accordingly... Module mStart Public MainFrm As frmMain Public SetupDayFrm As frmSetupDay Public Sub main() MainFrm = New frmMain Application.Run(MainFrm) End Sub End Module I'm not sure how to display forms modally or otherwise as yet... And how can you edit the constructors of a form to do what you have sugested? Many thanx
-
Hey there... I know this is gonna sound like a pretty easy thing to solve, as I'm learning a lot about vb.net as I go along - I'm learning that Micro has reinvented the wheel and made our lives that little bit more difficult. Well not really but having to relearn all the syntax and logic flow is a bit annoying. The problem I am having it with a SDI App I a writing, I have a main form, with a settings form that is loaded with the click of a button. I am trying to pass the variables from the settings form to the Main form. Some of the settings are in listboxes and some are in comboboxes. in VB6 you used to be able to do the following form1.listbox1.list = form2.listbox.list but now you can't - Damn Java look-a-like VB.net!!! :mad: :confused: Apparently there is a way to do it with modal forms and/or form inheritance - But as I'm still learning there is a lot I don't know. Would someone please assist me with this regard? Even the smallest amount of code/help would be greatly appreciative. Thanx in advance.
-
Right wrong coding there I know I am sorry... To add items to the second list box from the first, do: listbox2.items.add(listbox1.text)