Hi All, I posted this under XML but after reading some of the other posts, it was probably the wrong message board so here it is. OK I have worked out the below code to return the 'EN' string if I supply the string code, say "1000" of the below XML file but what I need to know is how to search for the string and return the string code. If I could use a wildcard in this it would be great. Any Thoughts??? Private Sub XPathSearch(ByVal XMLPath As String) Dim xmlNI As XPathNodeIterator Dim xpathDoc As XPathDocument Dim xmlNav As XPathNavigator Try xpathDoc = New XPathDocument(XMLPath) xmlNav = xpathDoc.CreateNavigator() xmlNI = xmlNav.Select("/MOMLANG/STRING[@code='" & stringValue & "']/LANG[@code='EN']") While (xmlNI.MoveNext()) 'Me.RichTextBox1.AppendText(xmlNI.Current.Name + " : " + xmlNI.Current.Value & vbCrLf) Me.RichTextBox1.AppendText("String value: " + xmlNI.Current.Value & vbCrLf) End While Catch ex As XPathException System.Console.WriteLine("XMLException: " + ex.Message) Catch ex As Exception System.Console.WriteLine("Exception: " + ex.Message) End Try End Sub I have worked with reading simple XML elements but have not worked with atributes and the like. I am also new to both XML and Dev in general. I have read several articles but most give me examples for reading simple XML e.g. John Smith The file I am trying to read is below, any help would be great and examples are very much welcome. My goal for the GUI in VB.NET will be to have a textbox to enter string number I am searching for and a dropdown but to select the language. Regards Jason Access Allowed List Access Allowed List Access Allowed List Access Allowed List Access Allowed List Access Allowed List Lista de accesos permitidos Pääsylista sallitut Liste des accès autorisés Access Allowed List Hozzáférés Engedély Lista Elenco accessi consentiti
japel
Posts
-
XML XPath search in vb.net -
Read XML from VB.NET [modified]Hello, OK I have worked out the below code to return the 'EN' string if I supply the string code, say "1000". What I need to know is understand how to search for the string and return the string code. If I would use a wildcard in this it would be great. Any Thoughts??? Private Sub XPathSearch(ByVal XMLPath As String) Dim xmlNI As XPathNodeIterator Dim xpathDoc As XPathDocument Dim xmlNav As XPathNavigator Try xpathDoc = New XPathDocument(XMLPath) xmlNav = xpathDoc.CreateNavigator() xmlNI = xmlNav.Select("/MOMLANG/STRING[@code='" & stringValue & "']/LANG[@code='EN']") While (xmlNI.MoveNext()) 'Me.RichTextBox1.AppendText(xmlNI.Current.Name + " : " + xmlNI.Current.Value & vbCrLf) Me.RichTextBox1.AppendText("String value: " + xmlNI.Current.Value & vbCrLf) End While Catch ex As XPathException System.Console.WriteLine("XMLException: " + ex.Message) Catch ex As Exception System.Console.WriteLine("Exception: " + ex.Message) End Try End Sub When people make you see red, be thankful your not colour blind.
-
Read XML from VB.NET [modified]Hello, I am trying to read the attached XML file by entering the and return the value for Access Allowed List. I have worked with reading simple XML elements but have not worked with atributes and the like. I am also new to both XML and Dev in general. I have read several articles but most give me examples for reading simple XML e.g. John Smith The file I am trying to read is below, any help would be great and examples are very much welcome. My goal for the GUI in VB.NET will be to have a textbox to enter string number I am searching for and a dropdown but to select the language. Regards Jason Access Allowed List Access Allowed List Access Allowed List Access Allowed List Access Allowed List Access Allowed List Lista de accesos permitidos Pääsylista sallitut Liste des accès autorisés Access Allowed List Hozzáférés Engedély Lista Elenco accessi consentiti Access Allowed List Liste over systemtilgang Access Allowed List Access Allowed List Använda tillÃ¥ten lista المطبوعة: Vytisknuto: Gedruckt: Printed: Prinditud: Printed: Impreso: Tulostettu: Imprimé: Printed: Nyomtatott: Printed: Stampato: Afgedrukt: Skrevet ut Wydrukowano: Ðапечатано: Utskrivet:
When people make you see red, be thankful your not colour blind. modified on Thursday, September 11, 2008 8:47 AM
-
query of select max numberSorry didn't read you post very well. SELECT Max(myIDColumn - 1) FROM myTable
When people make you see red, be thankful your not colour blind.
-
query of select max numberHere you go... SELECT Max(myIDColumn) FROM myTable This will return the highest number in a column from a table.
When people make you see red, be thankful your not colour blind.
-
Sync Access with SQL2005Hi All I am writing an app that is a time tracking systray utility but the scope has grown. The Version 1 release used a local Access DB to store Data but now management want to sync it centrally to an SQL server so group wide reports can be pulled. In short I am looking for direction on the best way to tackle this. SQL Sample Table CustomerID (int) Identity = Y (i.e. Auto incrementing) CustomerName (Text 50) DeleteFlag (int) RecordTimeStamp (timestamp) MS Access CustomerID (int) I Get the SQL ID for the record and put here) CustomerName (Text 50) DeleteFlag (int) My first thought (well within the first 10) was to check the SQL timestamp and only add records that were newer that the last stored timestamp. Thoughts
When people make you see red, be thankful your not colour blind.
-
Write service to fail or crash.The article was interesting from a error handling point of view. I was looking for the opposite, I need a service to fail the triggers the service recovery option and let's me run a program. Thanks
When people make you see red, be thankful your not colour blind.
-
Write service to fail or crash.Hi All I am writing am app that I can call from the windows services recovery tab that emails me when the service fails. At present I have a written a service that has a counter that has a 10 second delay that throws an exception. But on testing the service it counts 10 ten sec's and crashes but never launches the test app from the service recovery tab (Notepad). Is the unhandled exception the same as a service failing? How do I write an app that crashes for testing? IDEAS.... P.S. What is even more annoying is that if I was writing a service it would have heaps of errors to debug and now the apposite :mad: Thanks
When people make you see red, be thankful your not colour blind.
-
Working with command line arguments.In the past I have done this with a getargs sub but why is there a system.environment.getarguments if it is so limited. It must be how I am implementing it. This was the way I was doing it.
Function GetCMDArgs() As String() ' Declare variables. Dim separators As String = " " Dim commands As String = Microsoft.VisualBasic.Interaction.Command() Dim CMDargs() As String = commands.Split(separators.ToCharArray) Return CMDargs End Function
When people make you see red, be thankful your not colour blind.
-
Listview Data to XMLI used this artical and it was great. http://www.knowdotnet.com/articles/serializationoflistviewtoxml.html Good luck...
When people make you see red, be thankful your not colour blind.
-
Working with command line arguments.I am working on a Console application at I wish to use arguments with. I am using VS2005 system.environment.getarguments... This returns a string array separated by a space. This does not help if the arg I am trying to pass has spaces. How to I set the GetArgs to use a - or / as the separate (switch)? At present I am writing the array back as a single string and using split to separate in the - but this is wrong I know. Does anyone have advice / tutorial explaining this. Please NO cut and paste code.... Thanks
When people make you see red, be thankful your not colour blind.
-
Handling exit (X) button at the top right cornerYou need to catch the (On_Close) event for the close button.
Private Sub OnClosingForm() Dim Result As DialogResult Result = MessageBox.Show("Are you sure you with to exit Time-Keeper?" & vbCrLf & _ "Press OK to Exit & Close, Press No to mimimise to the system tray.", "Confirmation on action!", _ MessageBoxButtons.YesNo, MessageBoxIcon.Question) If Result = Windows.Forms.DialogResult.Yes Then Me.Close() Else Me.WindowState = FormWindowState.Minimized Me.Hide() End If End Sub Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Me.Dispose() End Sub This is a code and not a Vista question, if you have further question please post on a form dedicated to your chosen language (C# or VB.Net). Hope this helps.
When people make you see red, be thankful your not colour blind.
-
Detect Windows XP SP2 firewall.Hi I am trying to programmatically test if the windows firewall is enabled or not. I guess there is a value for this in the registry but I wanted to ask here for any better solutions to do this test. Maybe WMI if posible? Any Thoughts? Thanks:doh:
When people make you see red, be thankful your not colour blind.
-
VB script not workng on Win 2000This script works great on the XP box I wrote it on but not on a Win 2000 box. The script was found while Googling and I have added the rename sub and a few other changes to suite my required task. I am reletivly new to dev and am not sure if the problem is win2k supporting the script or if the script needs changing. The problem is at line 70 creating the tcp ip ports. if I take this out the script runs to completion telling me the printers are added but they are not. I manually added the ports and re ran the script but no luck. Please help...
'This script will add ip ports for your local printers and attach printers to 'those ports. Just edit the arrays to reflect the paths for the .INF files 'and get the printer descriptions from the .INF files. If the printer is listed 'in the system32/inf/ntprint.inf use that as the .INF it tells the script where 'to look for the driver otherwise use the UNC path to get the path. '=================================================== strComputer = "." 'strComputer can be an array of netbios computer names or 'ip addresses put into a for loop '=================================================== Public Error Dim Count:Count=0 Set WshShell = WScript.CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Wscript.echo "This process may take several minutes please be patient." & VbCrLf _ & "Another pop-up box will inform you when it is finished." 'Here is where your edit the port IP addresses '=================================================== Dim IPArray IPArray = Array( "192.168.100.1","192.168.100.1") Dim PrintersArray '=================================================== 'Here is where you enter the driver inf paths PrintersArray=Array("C:\CanonDrivers\win2k_xp_PCLModBW\P52KUKAL.INF",_ "C:\CanonDrivers\win2k_xp_PS_2-9\W2KPS3K.INF") '=================================================== 'Here is where you edit the printer names Dim PrinterNames PrinterNames=Array("Canon iR C5180 PCL5c", "Canon iR C5180 PS3") '=================================================== 'Here is where you edit the new printer names Dim PrinterNewNames PrinterNewNames=Array("Black and White", "Colour") '=================================================== For n = LBound(IPArray) To UBound(IPArray) 'Install the IP printer ports Install_IP_Ports IPArray(n) Next For n = LBound(IPArray) To UBound(IPArray) Count = Count + 1 'just increments the counter for the message at the end!
-
Console.Write to TextBoxHello In the below code I found on the internet I would like to use in a vb app and have the result in a multi line text box but I Console.Write line gives me an error. I Tryed
Textbox1.Text = ("IP Address {0}: {1} ", i, IpA(i).ToString)& VbCrlf
Any thoughts? If there is better code out there that might also get subnet and gateway that would be great. Thanks Heaps'To get local address Dim sHostName As String Dim i As Integer sHostName = Dns.GetHostName() Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName) Dim IpA() As IPAddress = ipE.AddressList For i = 0 To IpA.GetUpperBound(0) Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString) Next
When people make you see red, be thankful your not colour blind.
-
Using ImageList with Listview QuestionI have a app with a listview on a form set to detailsview. This works great but now I would like to add small image icons. In the listview controle is a "smallimagelist" property that is set to none and I can not change that...? Below is the code I use to populate the listview on load.... How can I modify my code to allow small icon view mode?
Public Sub ReloadListviewFromXML() Dim AddressBook As String = (Path.Combine(Application.StartupPath, "AddressBook.xml")) Dim ds As New DataSet Try ds.ReadXml(AddressBook) Dim dt As DataTable = ds.Tables("People") Dim i As Integer Dim j As Integer Me.listviewObjects.Items.Clear() For i = 0 To dt.Rows.Count - 1 Dim dr As DataRow = dt.Rows(i) With Me.listviewObjects .Items.Add(dr(0)) For j = 1 To dt.Columns.Count - 1 .Items(i).SubItems.Add(dr(j)) Next End With Next Catch ex As System.Exception End Try listviewObjects.GridLines = True listviewObjects.FullRowSelect = True listviewObjects.MultiSelect = True End Sub
Thanks...When people make you see red, be thankful your not colour blind.
-
Pass wild card value to Where Like Statement.Running this query from access it does not ask me for an input it is looking for a user of %myVar% As it is in the ' ' string quotes... I have already found this and tryed it... Any other thoughts..... ?
When people make you see red, be thankful your not colour blind.
-
need code sampleThis is a very open question... What type of database??? If you just need the connection string check our http://www.connectionstrings.com Also do you want to perform inline SQL / Procedures or use the VS ADO database objects... Not much help but not much to go on... :)
When people make you see red, be thankful your not colour blind.
-
Pass wild card value to Where Like Statement.I have the below query but would like to use a wild card value to do the search. I need to pass a value like "on" and find, Jason or Preston. It would be nick if it is also not case sensitive.... This value is coming from VB.Net App and this is messing with me... My Access (SQL) statement is: SELECT * FROM MainTB WHERE myCustomer Like [@myVar]; But the LIKE needs to be [%myVar%] I think. Feedback welcome please......
When people make you see red, be thankful your not colour blind.
-
[Message Deleted]In the future please supply your teachers detail so the forum members can submit your homework for you and save you the trouble... ;P
When people make you see red, be thankful your not colour blind.