Visual Basic Language ForumQuestions and discussions regarding the VB language, compiler, VB framework/runtime – including things like generics, language keywords, My namespace. (Not for VB6)© 2009 Microsoft Corporation. All rights reserved.Wed, 25 Nov 2009 19:15:10 Z7d82547a-0253-4a8c-8ff4-a4883f409aadhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/e9fdcad4-294a-4a9b-bdd8-30948acce8a8http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/e9fdcad4-294a-4a9b-bdd8-30948acce8a8HakanKocakhttp://social.msdn.microsoft.com/Profile/en-US/?user=HakanKocakAddhandler events of an Object ?Hello,<br/> <br/> I have a number of UserControls that have the same event .<br/>  <br/> When I use an Object instead of UserControl, I can not use Addhandler.<br/> <br/> Here is the simplest example of my problem:<br/> In this example error is &quot;TextChanged is not an event of Object&quot;<br/> <pre lang=x-vbnet>Dim obj As Object = TextBox1 AddHandler obj.TextChanged, AddressOf text_changed_event</pre> I have to use this structure, because in a FOR loop I use some different UserControls as obj.<br/> All UserControls have the same event.<br/> <br/> Is there a way to use this structure without error?<br/> <br/> Maybe there is a way to define a new object that covers all my UserControls.<br/> <br/> Thanks.<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/>Wed, 25 Nov 2009 16:17:49 Z2009-11-25T19:15:10Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/b9764ff1-c09f-4c22-a44e-75be9f66c0f0http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/b9764ff1-c09f-4c22-a44e-75be9f66c0f0Tom R.1956http://social.msdn.microsoft.com/Profile/en-US/?user=Tom%20R.1956How to Programatically change SelectedTab in a TabControlEventI have a TabControl with 4 TabPages ( 0, 1, 2 &amp; 3 ).  As the user changes from Tab to Tab, a validation procedure determines if the selections in the curent tab are complete.  I'm using the 'Selecting' event to check for the validation and if not valid I'm setting e.cancel to true.<br/><br/>All of this works quite well.  My problem is that in the validation code, checking tab(1) data, I would like to offer the user the ability to choose to change data in tab(0).  The 'Selecting' event enables me to cancel the change to tab(2) from tab(1) but will not allow me to set the selectedindex to 0.<br/><br/>Any Ideas??<br/><br/>Thank you,<br/>Tom R.<hr class="sig">vba &amp; vb6 programmerFri, 20 Nov 2009 06:32:52 Z2009-11-25T19:12:02Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/75b5b93b-7abd-4d4b-b7b6-98132c5fed5fhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/75b5b93b-7abd-4d4b-b7b6-98132c5fed5fMBASIChttp://social.msdn.microsoft.com/Profile/en-US/?user=MBASICSetLastWriteTime is off by 1 hourI've written a console utility to set file date/time stamps to a specified date/time: <br><font size=2> <p></font><font color="#0000ff" size=2><font color="#0000ff" size=2>For</font></font> <font color="#0000ff" size=2><font color="#0000ff" size=2>Each</font></font><font size=2> FoundFile </font><font color="#0000ff" size=2><font color="#0000ff" size=2>In</font></font> <font color="#0000ff" size=2><font color="#0000ff" size=2>My</font></font><font size=2>.Computer.FileSystem.GetFiles(FileSpecPath, FileIO.SearchOption.SearchTopLevelOnly, WildCards)<br>    FileInfo = </font><font color="#0000ff" size=2><font color="#0000ff" size=2>My</font></font><font size=2>.Computer.FileSystem.GetFileInfo(FoundFile)<br>    System.IO.File.SetCreationTime(FileInfo.FullName, NewDate)<br>    System.IO.File.SetLastWriteTime(FileInfo.FullName, NewDate)<br>    System.IO.File.SetLastAccessTime(FileInfo.FullName, NewDate)<br>    Console.Write(FileInfo.Name + </font><font color="#a31515" size=2><font color="#a31515" size=2>&quot; &quot;</font></font><font size=2> + NewDate)<br></font><font size=2><font color="#0000ff" size=2><font color="#0000ff" size=2>Next</p></font></font></font> <p><font size=2>When I go to a command prompt to check the results, the new date is correct, but the hour is off by 1 hour. Same when I check the times in Windows Explorer -- all three times are displayed to the same time, but exactly 1 hour earlier.<br><br>The system date/time are correct (Vista) and we are not in DST.<br>The files reside on a local drive (not a network share).<br>The computer is not on a domain.<br><br>I was about to tinker with the SetUTC functions, but thought I'd ask first.<br>Thanks,<br> -Jack</p></font>Fri, 16 Jan 2009 23:53:47 Z2009-11-25T18:36:54Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/cf6afe37-0d94-4711-b614-2da19bdb33a0http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/cf6afe37-0d94-4711-b614-2da19bdb33a0vishvishal2000http://social.msdn.microsoft.com/Profile/en-US/?user=vishvishal2000Need a Calendar!Hello Everyone!<br/> <br/> I wanna insert a calendar on my VB form. I can drag it to the form from the toolbox, but I don't understand how I can creating to do list on different dates.<br/> I mean I need a calendar where after clicking a certain dates, it can show me what the activities gonna be on that day. <br/> Any ideas about using the calendar?<br/>Tue, 24 Nov 2009 10:28:37 Z2009-11-25T17:51:23Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/6c51af6a-f4f3-4019-8cee-e54e82924241http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/6c51af6a-f4f3-4019-8cee-e54e82924241BrianMcCumberhttp://social.msdn.microsoft.com/Profile/en-US/?user=BrianMcCumberHow can I check if a wav file is playing?Hello. I am using VS 2005 Professional and writing a guitar tuner app with visual basic. I have a 6 wav files that play in button click events using the My.Computer.Audio.Play() method. I need to animate a picture box meter while a wav file is playing.  I have searched in the library, but I can't find any relevant info for checking if a sound is playing for vb. Is there a way I can check to see if the wav file is playing? <br/>Tue, 24 Nov 2009 16:52:30 Z2009-11-25T15:52:25Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/012244b7-db20-47b1-9351-86d376996e02http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/012244b7-db20-47b1-9351-86d376996e02bertVBhttp://social.msdn.microsoft.com/Profile/en-US/?user=bertVBToString format<span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>Private</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span> <p><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Sub</span></span><span style="font-size:x-small"> submitButton_Click(</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">ByVal</span></span><span style="font-size:x-small"> sender </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> System.Object, </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">ByVal</span></span><span style="font-size:x-small"> e </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> System.EventArgs) </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Handles</span></span><span style="font-size:x-small"> submitButton.Click<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Dim</span></span><span style="font-size:x-small"> average </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Integer</span></span><span style="font-size:x-small"> = 0<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Dim</span></span><span style="font-size:x-small"> score </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Integer</span></span><span style="font-size:x-small"> = 0<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Dim</span></span><span style="font-size:x-small"> number </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Integer</span></span><span style="font-size:x-small"> = 0 <p>score = Convert.ToInt32(scoreTextBox.Text)</p> <p>taken += 1</p> <p>totalScore = score + taken</p> <p>average = Convert.ToInt32(totalScore / taken)</p> <p>average = Convert.ToInt32(averageResultLabel.Text) - SAYS MY INPUT STRING IS NOT IN CORRECT FORMAT</p> <p> </p> <p>number = Convert.ToInt32(numberResultLabel.Text)</p> <p> </p> <p> </p> <font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">End</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Sub<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>End</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Class</span></span><span style="font-size:x-small"> </span><span style="color:#008000;font-size:x-small"><span style="color:#008000;font-size:x-small">' QuizAverageForm</span></span></p>Tue, 24 Nov 2009 22:15:39 Z2009-11-25T15:33:21Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/97ac40cb-e7f8-445d-95d9-d56c0f2c5932http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/97ac40cb-e7f8-445d-95d9-d56c0f2c5932JMANCIhttp://social.msdn.microsoft.com/Profile/en-US/?user=JMANCIVB.NET Format Phone NumberI'm trying to format a phone number in VB.NET 2008 in the code. A user can type in this number for example: (203) 555-1212<br/><br/>The format I would like the phone numbers to appear is this:<br/>203.555.1212<br/><br/>I haven't been able to find the correct format.<br/><br/>I tried this:<br/><span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">Dim</span></span><span style="font-size:x-small"> x </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">As</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">String</span></span><span style="font-size:x-small"> = </span><span style="font-size:x-small;color:#a31515"><span style="font-size:x-small;color:#a31515">&quot;(222) 333-4444&quot;<br/><br/><span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">Dim</span></span><span style="font-size:x-small"> joe </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">As</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">String</span></span><span style="font-size:x-small"> = </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">String</span></span><span style="font-size:x-small">.Format(</span><span style="font-size:x-small;color:#a31515"><span style="font-size:x-small;color:#a31515">&quot;{0:###.###.####}&quot;</span></span><span style="font-size:x-small">, x)<br/><br/>This doesn't do anything to the variable. I've tried to set my variable x to '2223334444', but the format still does not work. Any ideas? <br/></span></p> </span></span></p>Mon, 23 Nov 2009 17:06:54 Z2009-11-25T15:28:51Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/30cf7a25-4b26-46c1-ab52-74c55f7a55f8http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/30cf7a25-4b26-46c1-ab52-74c55f7a55f8kwazuluhttp://social.msdn.microsoft.com/Profile/en-US/?user=kwazulucalculating compound intrestformula for compound intrest is  P(1+r)n <br/>Iwould like to know what function procedure would i use to calculae this formula.<br/>I am using textboxes for the veriables.Wed, 25 Nov 2009 13:47:22 Z2009-11-25T15:17:38Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/b1b5fbd4-e56e-4c90-bd7b-f4b85048d8e5http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/b1b5fbd4-e56e-4c90-bd7b-f4b85048d8e5JackDKhttp://social.msdn.microsoft.com/Profile/en-US/?user=JackDKMS access permission problem<pre class=FreeTextFull>Hi all,<br/>        My application using Ms Access DB. when i connect to DB  from client machine <br/> it show error at conn.open. the error was &quot;you need permission to view its data&quot;.<br/> If I login to the server, it works perfectly.<br/> <br/>    The connection string was &quot;provider=microsoft.jet.oledb.4.0;Jet OLEDB:Database<br/> Password=pwd;data source=\\&quot; &amp; SerIP &amp; &quot;\NTDB\Config.mdb&quot;<br/> (server IP - SerIP, NTDB - shared folder in server)<br/> <br/>      <br/> Is there any way to access the DB from code without server login? pls guide me<br/> <br/> </pre>Wed, 18 Nov 2009 07:01:36 Z2009-11-25T13:31:48Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/0b08db5c-4b48-4d8b-af31-d3af9b095f66http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/0b08db5c-4b48-4d8b-af31-d3af9b095f66mipaktehhttp://social.msdn.microsoft.com/Profile/en-US/?user=mipaktehdbnull in textboxt to datagridviewhi everbody.........<br/><br/>this code i pick from grauva khanna...<br/>it working..but for one coulmn only..<br/>my question is ..how to manipulate every column with dbnull.value<br/><br/> <pre> 'If TextBox1.Text.Trim = &quot;&quot; And TextBox2.Text.Trim = &quot;&quot; And TextBox3.Text.Trim = &quot;&quot; And TextBox4.Text.Trim = &quot;&quot; Then 'DT.Rows.Add(DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value) 'ElseIf Not TextBox1.Text.Trim = &quot;&quot; And Not TextBox2.Text.Trim = &quot;&quot; And Not TextBox3.Text.Trim = &quot;&quot; And Not TextBox4.Text.Trim = &quot;&quot; Then 'DT.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text) 'ElseIf TextBox1.Text.Trim = &quot;&quot; And Not TextBox1.Text.Trim = &quot;&quot; And TextBox2.Text.Trim = &quot;&quot; And Not TextBox2.Text.Trim = &quot;&quot; Then 'DT.Rows.Add(DBNull.Value, TextBox1.Text, DBNull.Value, TextBox4.Text) '' ElseIf Not TextBox3.Text.Trim = &quot;&quot; And TextBox3.Text.Trim = &quot;&quot; And Not TextBox4.Text.Trim = &quot;&quot; And TextBox4.Text.Trim = &quot;&quot; Then 'DT.Rows.Add(TextBox1.Text, DBNull.Value, TextBox3.Text, DBNull.Value) ' End If</pre> thank.............Tue, 24 Nov 2009 10:21:15 Z2009-11-25T10:08:58Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29e96613-4b54-4111-a973-9907a14ec774http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29e96613-4b54-4111-a973-9907a14ec774enirys9http://social.msdn.microsoft.com/Profile/en-US/?user=enirys9VB.NET 2005 SOCKET PROBLEMhi every one, <br/>i'm developping a server application using vb.net and i'm facing a problem. in fact i have a hudge data to send to the client via the socket so i use a loop  to divide the data and send eatch part the problem is that when i proceed with the sending the socket send me only few peaces of the data and loose a big part of it. i tryed to flush the buffer after each sending but i didnt find how to do it so i used a system.threding.thread.sleep between each socket.send. it wors when i don't have hudge data but it blocks my server when the number of paquets increases. is there a solution that would replace the .sleep one without blocking the application??Wed, 25 Nov 2009 08:30:34 Z2009-11-25T08:30:35Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/36210c16-81a0-414c-aff8-b4cfe545d65bhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/36210c16-81a0-414c-aff8-b4cfe545d65bEgoZahttp://social.msdn.microsoft.com/Profile/en-US/?user=EgoZaAudio stream capture from webHi.<br/><br/>I have link: <a href="http://www.trancearoundtheworld.com/player/play.php?id=294">http://www.trancearoundtheworld.com/player/play.php?id=294</a><br/><br/>I want capture the audio stream on my computer in mp3/wav.<br/><br/>I have no idea from what i should start. What should i use for start developing? I'm working in VS2008 on VB. Can i do it in VB? What additional software i need? If anyone has source code example/any docs pls post it pls. <br/><br/>Thanks in advance!Wed, 18 Nov 2009 16:59:23 Z2009-11-25T07:20:30Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/0c2c4a54-f599-48fb-9f92-fad791ea9fafhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/0c2c4a54-f599-48fb-9f92-fad791ea9fafTalimorehttp://social.msdn.microsoft.com/Profile/en-US/?user=TalimoreNeed help with Management System Project, Searching a TXT file and getting data when clicking in a listbox.I will include a link to a copy of my source Code. The Problem is that I have to create a user management system. I have almost all my features working but there are one or two I can't get working. When the program loads a text file is read and the program lists the first name of everyone in the text file into a list box. I want to be able to get so that when you click a name in the list box, the persons information will be displayed in the text boxes to the left. And also when you edit those text boxes you can click the button for modify current and it will modify that persons data. The other problem I'm having is being able to search that text file for the users e-mail and return the first names of people who have that e-mail into the listbox. Please help: It will make more sense if you look at my code, so I am including a copy of it here.<br/> <br/> Link to Source Project:<br/> http://whatwereplaying.com/Project.rar<br/> <br/> Thank you to everyone who helps me!Tue, 24 Nov 2009 07:52:37 Z2009-11-25T05:06:21Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/f4abe22c-db28-4f3b-8c6d-50bb05b2e583http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/f4abe22c-db28-4f3b-8c6d-50bb05b2e583Steffen064http://social.msdn.microsoft.com/Profile/en-US/?user=Steffen064Tab Import does not work with Microsoft.Jet.OLEDB; CSV works even though FMT=TabDelimited<span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="font-size:x-small"> <p>I am trying to import a tab delimited file with ADO. If I convert my tabs to csv it works, but I would like to know why it does not work with tab.<br/>The Function is on the buttom<br/><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small"><span style="font-size:x-small">here is my test data:<br/><br/>Test1:<br/>- Create a Text file with Headers: Test1, Test2, Test3 <br/>and rows: <br/>row1: 1,2,3; row2: 4,5,6; row3: 7,8,9<br/><br/>I create the file in Excel and export it from excel, if I read it back in as a delimited file it recognizes the tabs and displays it correctly.<br/><br/>here is the test file in hex:<br/>54 65 73 74 31 09 54 65-73 74 32 09 54 65 73 74   |Test1.Test2.Test|&quot;<br/>33 0D 0A 31 09 32 09 33-0D 0A 34 09 35 09 36 0D   |3..1.2.3..4.5.6.|&quot;<br/>0A 37 09 38 09 39                                 |.7.8.9          |&quot;<br/><br/><br/>I followed link:<br/><a href="http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/9ac36a61-8556-4b50-861e-11db2d36b1d1/">http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/9ac36a61-8556-4b50-861e-11db2d36b1d1/</a><br/>but it does not help me<br/><br/>My output in my datagrid is:<br/>Test1_Test2_Test3 for the header<br/>1|2|3, the | is really a square box which indicates the Tab I suppose.<br/>4|5|6<br/>7|8|9<br/>I binged and googled and yahooed and now I am ready to do a snore..<br/><br/>I hope you guys can help me </span></span></span></span></span></span></span></span></span></span> <p>==== </p> <p>   Function ImportTab(ByVal StrFileName As String) As Boolean</p> <p>      Dim StrSql As String = &quot;&quot;<br/>      Dim strCSVConnStr = &quot;&quot;<br/>      Dim myString As String = &quot;&quot;<br/>      Dim strfile As String = &quot;&quot;</p> <p>      ImportTab = False<br/>      Try</p> <p>         strfile = StrFileName</p> <p>         Dim myConnection As New System.Data.OleDb.OleDbConnection( _<br/>             &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\AlarmData;&quot; &amp; _<br/>             &quot;Extended Properties='text;FMT=TabDelimited;HDR=YES'&quot;)</p> <p>         myConnection.Open()</p> <p>         StrSql = &quot;Select * From [TabData.txt] ;&quot;</p> <p>         Dim oleAdapter1 As New OleDb.OleDbDataAdapter(StrSql, myConnection)</p> <p>         Dim dtbCSV As New DataTable<br/>         oleAdapter1.Fill(dtbCSV)<br/>         DataGridView1.DataSource = dtbCSV<br/>         DataGridView1.Focus()<br/>         ImportTab = True</p> <p>      Catch ex As System.InvalidOperationException<br/>         Debug.Write(ex.Message)<br/>         ImportTab = False<br/>      End Try</p> <p>   End Function<br/><br/>################### </p> </p> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> <p>Just found that If I use a normal txt file with comma separated content then this function will display it correctly. It is like the fmt has no function. </p> </span></span></span><span style="color:#0000ff;font-size:x-small"> <p> </p> </span></span> <p> </p>Wed, 25 Nov 2009 04:41:04 Z2009-11-25T04:41:05Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/03eab6c8-0aa9-4724-ae75-b73a832470e5http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/03eab6c8-0aa9-4724-ae75-b73a832470e5Erik Svensenhttp://social.msdn.microsoft.com/Profile/en-US/?user=Erik%20SvensenSimple Linq to XML questionHi<br/><br/>Could someone help a newbie into the LINQ <br/><br/>I would like to retrieve the value of the &lt;Name&gt; and &lt;Value&gt; node for each &lt;Parameter&gt; element from this XML <br/><br/>The XML is loaded from a text string.<br/><br/> <pre lang=x-xml>&lt;Parameters xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns=&quot;urn:schemas-microsoft-com:xml-analysis&quot;&gt; &lt;Parameter&gt; &lt;Name&gt;Datasource&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Datasource].[Datasource].&amp;amp;[2]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;ToPeriod&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Time].[YWD].[Year].&amp;amp;[2009].&amp;amp;[2009 sem 47]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;Chain&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Stores].[Chain hierarchy].[Chain].&amp;amp;[2]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;Category&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Products].[CRF Category].[All]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;ShowTopProducts&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;20&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;ShowTopStores&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:int&quot;&gt;40&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;DistrictManager&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Stores].[District Manager].[All]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;AreaManager&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Stores].[Area Manager].[All]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;Consultant&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Stores].[Consultant].[All]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;CommercialRegion&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Stores].[Commercial region].[All]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;PotentialGroup&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Stores].[Potential Group].[All]&lt;/Value&gt; &lt;/Parameter&gt; &lt;Parameter&gt; &lt;Name&gt;PricePeriod&lt;/Name&gt; &lt;Value xsi:type=&quot;xsd:string&quot;&gt;[Time].[YMD].[Year].&amp;amp;[2009].&amp;amp;[Agosto 2009]&lt;/Value&gt; &lt;/Parameter&gt; &lt;/Parameters&gt;</pre> Should be relatively simple but I simply can't crack the nut<br/><br/>Thx<br/><br/>ErikTue, 24 Nov 2009 23:43:10 Z2009-11-25T01:23:25Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/3f0b2622-193b-434a-9d27-765ec6ae3eeahttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/3f0b2622-193b-434a-9d27-765ec6ae3eeaallan77http://social.msdn.microsoft.com/Profile/en-US/?user=allan77SQL CODE PROBLEM<p>Dear all, I'm using SQL as a database in VB 2010, I already add a table to my form as a datagrid view but I don't know how to add buttons for filtering, deleting and adding things in my table, for example I want to have one button on my form call it search button to search in table names or Phone Numbers. how can I do that and where shall I write the code?<br/>waiting for help.</p>Sun, 22 Nov 2009 20:49:13 Z2009-11-24T23:01:08Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/5de46d29-e707-4bbc-836b-2ae7ec490104http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/5de46d29-e707-4bbc-836b-2ae7ec490104Palash Aichhttp://social.msdn.microsoft.com/Profile/en-US/?user=Palash%20AichZebra Printing exception - Invalid Parameter: Name handle ExceptionI am using VB.Net code to print barcode label in Zebra TLP 2844 printer. And the printer is connected to system by USB port. When i execute the code i get an error &quot;Invalid Parameter : Name handle&quot; in the line <span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'">outFile = </span><span style="font-size:12pt;color:#0600ff;line-height:115%;font-family:'Times New Roman','serif'">New</span><span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'"> FileStream(_SafeFileHandle, FileAccess.Write) . Can you please help me to rectify this.<br/><span style="font-size:x-small;font-family:Verdana">As this is a USB port So i shared the printer and used the UNC path. But still i get the error. Below is the complete code<br/><br/> <p class=MsoNormalCxSpFirst><strong><span style="font-size:small"><span style="font-family:Times New Roman">Name Spaces<br/></span></span></strong><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Imports System.IO <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Imports System.Runtime.InteropServices </span></p> <p class=MsoNormalCxSpMiddle><span style="font-size:small;font-family:Times New Roman"> </span><strong><span style="font-size:small"><span style="font-family:Times New Roman">Here is the button click code</span></span></strong></p> <p class=MsoNormalCxSpMiddle style="line-height:normal"><span style="font-size:small;font-family:Times New Roman"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Dim</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _print </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">as</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">new</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> ZebraPrint <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_print.StartWrite(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;//ComputerName/PrinterSharedName&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">dim</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _Text </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">as</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> = </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;Print test&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_print.Write(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;A30,120,0,4,2,1,N,&quot;&quot;&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> &amp; _Text &amp; </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;&quot;&quot;&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_print.EndWrite()</span></p> <p class=MsoNormalCxSpMiddle style="line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <div style="border-right:medium none;padding-right:0in;border-top:windowtext 1pt solid;padding-left:0in;padding-bottom:1pt;border-left:medium none;padding-top:1pt;border-bottom:windowtext 1pt solid;mso-element:para-border-div"> <p class=MsoNormalCxSpMiddle style="border-right:medium none;padding-right:0in;border-top:medium none;padding-left:0in;padding-bottom:0in;border-left:medium none;line-height:normal;padding-top:0in;border-bottom:medium none"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Class</span></p> </div> <p class=MsoNormalCxSpMiddle style="line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Class</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> ZebraPrint <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; Private constants &quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Const GENERIC_WRITE </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> = &amp;H40000000 <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Const OPEN_EXISTING </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> = </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">3</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; Private members &quot;<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _SafeFileHandle </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Microsoft.Win32.SafeHandles.SafeFileHandle<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _fileWriter </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> StreamWriter <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> _outFile </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> FileStream </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; private structures &quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">&lt;StructLayout(LayoutKind.Sequential)&gt; _ <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Structure SECURITY_ATTRIBUTES <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> nLength </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> lpSecurityDescriptor </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> bInheritHandle </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Structure </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; com calls &quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Private</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Declare </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Function</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> CreateFile Lib </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;kernel32&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Alias </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;CreateFileA&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> (</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> lpFileName </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwDesiredAccess </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwShareMode </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, &lt;MarshalAs(UnmanagedType.Struct)&gt; </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByRef</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> lpSecurityAttributes </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> SECURITY_ATTRIBUTES, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwCreationDisposition </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> dwFlagsAndAttributes </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> hTemplateFile </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Integer</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Microsoft.Win32.SafeHandles.SafeFileHandle </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region <br/></span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#Region </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot; Public methods &quot;<br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> StartWrite(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> printerPath </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) <br/></span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Dim</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> SA </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> SECURITY_ATTRIBUTES </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">_SafeFileHandle = CreateFile(printerPath, GENERIC_WRITE, </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">0</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, SA, OPEN_EXISTING, </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">0</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:red;font-family:'Times New Roman','serif'">0</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">Try </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _outFile = </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">New</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> FileStream(_SafeFileHandle, FileAccess.Write) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter = </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">New</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> StreamWriter(_outFile) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            Catch ex </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Exception </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                System.Windows.Forms.MessageBox.Show(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;Can not find printer.&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">&quot;Warning&quot;</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Error</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">, Windows.Forms.MessageBoxDefaultButton.Button1) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Try </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> Write(</span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">ByVal</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> rawLine </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">As</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">String</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            If _fileWriter IsNot </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Nothing</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Then</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter.WriteLine(rawLine) </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> If </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Public</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> EndWrite() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            If _fileWriter IsNot </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Nothing</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Then</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter.Flush() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _fileWriter.Close() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">                _outFile.Close() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> If </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            _SafeFileHandle.Close() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">            _SafeFileHandle.Dispose() </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">        </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;font-family:'Times New Roman','serif'">Sub</span><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'"> </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">#End Region </span></p> <p class=MsoNormalCxSpMiddle style="margin:auto auto auto 0.25in;line-height:normal"><span style="font-size:12pt;color:black;font-family:'Times New Roman','serif'">  </span></p> <span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'">    </span><span style="font-size:12pt;color:#0600ff;line-height:115%;font-family:'Times New Roman','serif'">End</span><span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'"> </span><span style="font-size:12pt;color:#0600ff;line-height:115%;font-family:'Times New Roman','serif'">Class</span><span style="font-size:12pt;color:black;line-height:115%;font-family:'Times New Roman','serif'"> </span></span></span>Tue, 24 Nov 2009 15:31:44 Z2009-11-24T15:31:44Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/4178f547-0cbe-427c-b0df-337c1a5f5bedhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/4178f547-0cbe-427c-b0df-337c1a5f5bedebassadorhttp://social.msdn.microsoft.com/Profile/en-US/?user=ebassadorVB Application Startup Failure: Type Initializer ExceptionThe application works fine on Vista but throws this error on Windows 7:<br/>     -  The type initializer threw an exception.<br/><br/>This is the code that causes it:<br/> <pre lang=x-vbnet> Public UserName As String = String.Empty UserName = Environment.UserName </pre> <br/><hr class="sig">ebassador<br/> &quot;Find it, fix it, move on.&quot;Fri, 20 Nov 2009 21:05:28 Z2009-11-25T10:32:14Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/a6d03560-bdf2-4566-b4f3-ff3534279ed9http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/a6d03560-bdf2-4566-b4f3-ff3534279ed9Anthony Khttp://social.msdn.microsoft.com/Profile/en-US/?user=Anthony%20KConverting DLL's Created with VB.Net to Intermediate Language To Create Entry Points Within A DLL<p>In need of some desperate help. Has anyone had any experience with a software product called Pres? The programme provides a function (userhook) that can run externally created dll's as the programme offers no COM support. The basic requirements for the dll are as follow.<br/><br/>1, The dll requires a public function named UserInstruction <br/>2, The UserInstruction must have 5 parameters. The first and second of type long, the third a double array and the fourth and fifth    parameters required type is a string.<br/><br/>This all seems pretty simple. But as .NET doesnt support exporting functions within a DLL to allow direct public access to the function through third party software it becomes tricky. After doing some research it seems as though this isn't possible in .NET. The only way I can see to do this is to convert the dll to Intermediate Language and play around with it once this is converted and then convert the IL code back to a DLL. I found this on the following site <br/><br/><a href="http://www.c-sharpcorner.com/UploadFile/JTeeuwen/ExportManagedCodeasUnmanaged11262005051206AM/ExportManagedCodeasUnmanaged.aspx">http://www.c-sharpcorner.com/UploadFile/JTeeuwen/ExportManagedCodeasUnmanaged11262005051206AM/ExportManagedCodeasUnmanaged.aspx</a><br/><br/>After trying this when I try to use the DLL via Pres I am still getting no joy. If anyone could help it would be extremly grateful.<br/><br/>Thanks In advance <br/><br/>Anthony Krajniewski</p>Mon, 16 Nov 2009 16:06:11 Z2009-11-24T15:13:23Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/4ade59f2-5dcb-4385-883b-d27d727e805fhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/4ade59f2-5dcb-4385-883b-d27d727e805fMunnjohttp://social.msdn.microsoft.com/Profile/en-US/?user=MunnjoVB 2008 - Complementary Error Function?Hello,  <div><br/></div> <div>I'm a novice at VB and I need to calculate a complementary error function as part of a model I am programming.  In Excel 2007, the function is ERFC() however I can find no such function in VB.  Is there a straight forward way of adding this function (or calling up Excel to calculate it from VB)?</div> <div><br/></div> <div>Thanks in advance,</div> <div><br/></div> <div>Jon</div>Tue, 24 Nov 2009 14:50:58 Z2009-11-24T14:50:59Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/a82be244-2f57-4bf5-a8ef-d3cc80b83f51http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/a82be244-2f57-4bf5-a8ef-d3cc80b83f51GraemePhttp://social.msdn.microsoft.com/Profile/en-US/?user=GraemePCreateObject("Excel.Application") running VERY slowIn my vb.net applications, I do a lot of reading/writing to excel files.<br/><br/>This is one of the simpler bits of code I use:<br/><br/><span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Dim</span></span><span style="font-size:x-small"> objApp </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Object</span></span><span style="font-size:x-small">, objBook </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Object</span></span><span style="font-size:x-small">, objSheet </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Object<br/></span></span><span style="font-size:x-small">objApp = CreateObject(</span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;Excel.Application&quot;</span></span><span style="font-size:x-small">)<br/>objBook = objApp.Workbooks.Open(</span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;C:\maid2clean\M2CPrinters.xls&quot;</span></span><span style="font-size:x-small">)<br/>objSheet = objBook.Worksheets.Item(1)<br/>objApp.Visible = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">False<br/></span></span><span style="font-size:x-small">objApp.UserControl = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">False<br/></span></span><span style="font-size:x-small">NormalPrinter = Trim(objSheet.Range(</span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;a1&quot;</span></span><span style="font-size:x-small">).value)<br/>LabelPrinter = Trim(objSheet.Range(</span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;a2&quot;</span></span><span style="font-size:x-small">).value)<br/>PDFPrinter = Trim(objSheet.Range(</span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;a3&quot;</span></span><span style="font-size:x-small">).value)<br/>objBook.close()<br/>objApp.quit()<br/><br/>It's never been fast but in the last few weeks it seems to take forever.<br/>The &quot;createobject&quot; line is taking 4 seconds to run.<br/><br/>Is there a better way to do this, and is there any way I can find out why it's slowed down?</span></p>Tue, 24 Nov 2009 09:19:52 Z2009-11-24T14:33:08Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/e6a4e9c7-6651-4c47-8722-07cc7d380885http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/e6a4e9c7-6651-4c47-8722-07cc7d380885Steve from adzachttp://social.msdn.microsoft.com/Profile/en-US/?user=Steve%20from%20adzacCircular reference needed? -- hopefully not<p>A solution with multiple projects seems to want circular references...which I dont' want to add.  This can't be an uncommon problem to solve, but after reading, researching, and experimenting, I haven't yet found an answer.  How can I solve this problem?</p> <p>Project Foo contains most of the code for an application, including several classes.</p> <p>Project GUI is a library of Windows forms for the solution.</p> <p>Foo contains classes that the applications uses.  Foo uses some of GUI's forms for data input, and some to show results.  The Foo project thus seems to need a reference to GUI.  </p> <p>GUI does a lot of user data input, and thus needs to call methods in Foo defined and instantiated classes.  Thus, GUI seemingly needs a reference to Foo.</p> <p>Pointers to good sources of information on multi-project solutions would be tremendously appreciated.</p> <p>Steve</p>Wed, 21 Mar 2007 02:44:04 Z2009-11-24T13:36:21Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29a1c89f-180c-4a9f-bb1a-080dc7fb58d4http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29a1c89f-180c-4a9f-bb1a-080dc7fb58d4Ognyan Yuskeselievhttp://social.msdn.microsoft.com/Profile/en-US/?user=Ognyan%20YuskeselievReading dynamic disk status (WMI)<p class=MsoNormal style="margin:0cm 0cm 10pt"><span style="line-height:115%;font-family:'Verdana','sans-serif';color:black;font-size:8pt" lang=EN-US>Hi, i want to ask you if anyone knows a way to read Dynamic disk status (like rebuilding) true WMI.<br/>Thank you</span></p>Mon, 23 Nov 2009 15:08:47 Z2009-11-24T11:01:54Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/c0779dd0-da1f-486d-85e6-470df9f39a82http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/c0779dd0-da1f-486d-85e6-470df9f39a82makdutakduhttp://social.msdn.microsoft.com/Profile/en-US/?user=makdutakduhow to INDEX a foxpro table linked in MS access using VB.NET I have a foxpro table &lt;b&gt; INVENT.DBF&lt;/b&gt; linked  in MS ACCESS. When i tried to do  a search in the table from vb.net application, it is taking a long time.  So I want to index the foxpro table  and then use it for search.<br/>Here is the sample code i wrote in vb.net &lt;i&gt;<br/><span style="font-size:x-small;color:#008000"><span style="font-size:x-small;color:#008000"> <p>cn = New OleDbConnection(&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\database.mdb;Persist Security Info=False&quot;)<br/>cn.open()<br/><span style="font-size:x-small;color:#008000"><span style="font-size:x-small;color:#008000">cmd = New OleDbCommand(&quot;Create INDEX itmno_idx ON INVENT(ITEM_NO) &quot;, cn)<br/><span style="font-size:x-small">cmd.ExecuteNonQuery()&lt;/i&gt;<br/><br/>But I am getting error &quot;Cannot execute data definition statements on linked data sources&quot; <br/>What needs to be done to index a linked foxpro table  using VB.NET</span></span></span></p> </span></span>Thu, 10 Sep 2009 05:56:57 Z2009-11-24T05:50:24Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/b689fbf7-5a49-4056-b4a6-c09560d10250http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/b689fbf7-5a49-4056-b4a6-c09560d10250rohanpuranikhttp://social.msdn.microsoft.com/Profile/en-US/?user=rohanpuranikProblem in Date.ParseExact method:Hi i am developing an application in Vb.Net VS 2005 which accepts an XML and convert its node values in desired data type and assigne them to their corresponding variables. Here i am encountering an exception in converting a string value to datetime datatype:<br/> <p class=MsoNormal>I have a form on which a button is there. On its click event following code get executed:<br/> Its code is as under:</p> <div style="color:Black;background-color:White"> <pre> <span style="color:Blue">Private</span> <span style="color:Blue">Sub</span> Button1_Click(<span style="color:Blue">ByVal</span> sender <span style="color:Blue">As</span> System.Object, <span style="color:Blue">ByVal</span> e <span style="color:Blue">As</span> System.EventArgs) <span style="color:Blue">Handles</span> Button1.Click<br/> <br/> <br/> <br/> <span style="color:Blue">Dim</span> str <span style="color:Blue">As</span> <span style="color:Blue">String</span> <br/> str = <span style="color:#a31515">&quot;&lt;OrderXMLDS&gt;&lt;Order&gt;&lt;TimeOutAt&gt;2/28/2009 4:14:18 AM&lt;/TimeOutAt&gt;&lt;/Order&gt;&lt;/OrderXMLDS&gt;&quot;</span> <br/> <br/> <br/> GetOrderXML(str)<br/> </pre> </div> <p class=MsoNormal>where &quot;str&quot; is my desired xml. Here i have shown just one node with a value (i.e. TimeOutAt) otherwise XML consists of several other nodes as well. I want to convert it into DateTime datatype for which i have written GetOrderXML function. Its body is as under:</p> <br/> <pre>Private Sub GetOrderXML(ByVal sXML As String)<br/> 'Extracts the required structure and data from the XML <br/> 'and saves an xml file in correct path for this order.<br/> <br/> Dim oXmlDoc As New XmlDocument<br/> Dim oNode As XmlNode<br/> Dim oNodeList As XmlNodeList<br/> Dim dsXML As New DataSet<br/> Dim TimeOutAt As DateTime<br/> <br/> Try<br/> oXmlDoc.LoadXml(sXML)<br/> oNode = oXmlDoc.DocumentElement<br/> <br/> oNodeList = oNode.SelectNodes(&quot;/OrderXMLDS/Order/TimeOutAt&quot;)<br/> <br/> TimeOutAt = Date.ParseExact(oNodeList.Item(0).InnerText.Trim, &quot;M/d/yyyy h:mm:ss tt&quot;, New Globalization.CultureInfo(&quot;en-us&quot;))<br/> <br/> Catch ex As Exception<br/> MsgBox(ex.Message())<br/> <br/> End Try<br/> End Sub</pre> <p class=MsoNormal>Here i know very well that the format of 1st and 2nd parameter MUST match exactly in order to parse the date succesfully. Hence i have passed the value in XML in exact &quot;M/d/yyyy h:mm:ss tt&quot; format.  I have tested this code and it is running successfully on both Windows XP and Vista without any problem irrespective of the current culture and DTF of the machine on which it is executing.<br/> <br/> But after one year of its usage, one day (bad luck day i suppose) i encountered exception &quot;String was not recognized as a valid DateTime.&quot;    <br/> After struggling much with the date time settings on my machine (Windows XP) i discovered that this code is running in all the conditions of local culture and DTF settings except ONE: That is when the current culture is &quot;En-US&quot; and date time SEPARATOR is &quot;-&quot; or &quot;.&quot; instead of &quot;/&quot;. To my surprize it is running without giving any exception in all other cultures and date time formats and their separators. <br/> Now i got two questions to ask:<br/> <br/> 1) Why on earth this is happening that the code is not running when current culture of the machine, on which this code executes, is &quot;English-UnitedStates&quot; and date separator is other than &quot;/&quot;? It is running in all other culture and DTF formats and date separators (i.e. string value is getting converted to date time data type).<br/> <br/> 2) Is there any other method using which i can convert the string value coming in the XML to date time datatype and assign to variable TimeOutAt?<br/> <br/> Here it will be worth mentioning that it is a desktop application and can't potentially know the current culture and date time settings of the target machine (and also i dont need to). As i know that the string value which is to be converted to date time in in the format &quot;&quot;M/d/yyyy h:mm:ss tt&quot;     <br/> Please try this code and suggest me the possible solutions for the situation.<br/> <br/> Here are complete exception details as copied to clipboard in case they are helpful:<br/> <br/> System.FormatException was caught<br/>   Message=&quot;String was not recognized as a valid DateTime.&quot;<br/>   Source=&quot;mscorlib&quot;<br/>   StackTrace:<br/>        at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style)<br/>        at System.DateTime.ParseExact(String s, String format, IFormatProvider provider)<br/>        at Proj.Form1.GetOrderXML(String sXML) in ~Proj\Form1.vb:line 71</p>Tue, 17 Nov 2009 06:15:43 Z2009-11-24T05:06:05Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/99d23b57-367c-4aad-a37a-03b08a9015e7http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/99d23b57-367c-4aad-a37a-03b08a9015e7AirForce9797http://social.msdn.microsoft.com/Profile/en-US/?user=AirForce9797LINQ join queryI have a VB2008 Windows Form with a SDF database. The database contains two tables. The following query returns the records in DiskInfo that have a matching DiskNumber in the DataInfo table. How do I get it to return records in DiskInfo that DO NOT having a matching DIskNumber in the DataInfo table?<br/><br/>Dim DiskQuery =  From DQ in DiskInfo join DI in DataInfo on DQ.DiskNumber equals DI.DiskNumber Order By DQ.DiskNumber select DQ<br/> <p><span style="font-family:Consolas;font-size:x-small"></span></p>Mon, 23 Nov 2009 15:49:07 Z2009-11-25T00:36:14Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/0e5948fb-a9a1-477f-b73c-6404ffe3c8c1http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/0e5948fb-a9a1-477f-b73c-6404ffe3c8c1ChrisHollsthttp://social.msdn.microsoft.com/Profile/en-US/?user=ChrisHollstImageList Help for newbie<p>I have an imagelist with a number of pics that reference a state in the file name (ie: NY0001.jpg, NY0002.jpg, PA0001.jpg...).  Is there a way to use the filename rather than the index number to select a picture to display?<br/><br/>The only solution I can come up with is creating a separate array and then cross referencing this with the imagelist.<br/><br/>ie:<br/>Array1 (dimmed as a string)<br/>0 NY<br/>1 NY<br/>2 PA ...<br/><br/>ImageList1 (containing 51 images)<br/>0 NY0001.jpg<br/>1 NY0002.jpg<br/>2 PA0001.jpg ...<br/><br/>Then compare:<br/>For N = 0 to 50<br/>  If Array1(N) = &quot;NY&quot; Then<br/>    Picturebox1.Image = ImageList1.Images(N)<br/>  End If<br/>Next<br/><br/>This is only the general idea, I can work out a timer sequence to delay the display of individual images.  Since I want to be able to add pictures, the maintenence of a separate array to reference the picture names will get complicated.  Is there a better way to do this using only the imagelist and referencing the file names in that directly?<br/><br/>Thanks in advance for any help.<br/><br/><span style="font-size:x-small"><br/><font size=2> <p> </p> </font></span></p> <p> </p>Sun, 22 Nov 2009 05:40:38 Z2009-11-24T23:01:23Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/f037688a-7c87-4a95-a9e0-0053b4ad63efhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/f037688a-7c87-4a95-a9e0-0053b4ad63efIWonnaJoinMicrohttp://social.msdn.microsoft.com/Profile/en-US/?user=IWonnaJoinMicrovisual Basics Set Hotkey?It there a way where you dont type anything in the textbox, and you press F2 and then the textbox says F2 or if you press 1 on your numberpad, the textbox will say NUMPAD1, or something like that and if you press Ctrl on your keyboard the TextBox will say Ctrl <div><br/></div> <div>Im not &quot;NEW&quot; to VB, i pretty much know everythin cept this. I know MySQL with VB and all that.</div> <div><br/></div> <div>Hope you help answer the question!</div> <div><br/></div> <div><br/></div> <div><br/></div> <div>-Mogen</div> <div><br/></div> <div>anyone..??</div>Mon, 23 Nov 2009 23:08:38 Z2009-11-25T03:11:16Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/24ddd4a5-3d8a-4003-8fd2-ca9ea981889dhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/24ddd4a5-3d8a-4003-8fd2-ca9ea981889ddan maklenhttp://social.msdn.microsoft.com/Profile/en-US/?user=dan%20maklenI need a help with a code!<p>Hi,</p> <p>There I made a encoder and while I am making the decoder I got a problem whith a code<br/>Here is a picture for the error<br/><a title=Error href="http://img502.imageshack.us/img502/4100/errorw.png">http://img502.imageshack.us/img502/4100/errorw.png</a><br/>What I am tring to do is to decode the codes after dividing in by the the value of the textbox<br/>If the Picture is not clear here is the code:</p> <div style="color:black;background-color:white"> <pre><span style="color:blue">private</span> <span style="color:blue">sub</span> decoding() <span style="color:blue">Dim</span> newText() <span style="color:blue">As</span> <span style="color:blue">String</span> = Split(De_Input_text.Text, <span style="color:#a31515">&quot;,&quot;</span>) De_Output_text.Text = <span style="color:#a31515">&quot;&quot;</span> <span style="color:blue">For</span> I <span style="color:blue">As</span> <span style="color:blue">Integer</span> = 0 <span style="color:blue">To</span> newText.Length - 2 (newText(I)De_code_text.text)) De_Output_text.Text &amp;= Chr(<span style="color:blue">CInt</span>(Val(newText(I)))) <span style="color:blue">Next</span> <span style="color:blue">end</span> <span style="color:blue">sub</span> </pre> </div> <p>I am using VisualBasic 2005 Express Edition<br/> Thanks a lot</p>Sun, 22 Nov 2009 12:15:49 Z2009-11-23T23:37:53Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/80d76691-cba5-4947-b2be-6776b4d68988http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/80d76691-cba5-4947-b2be-6776b4d68988CraigMucklestonhttp://social.msdn.microsoft.com/Profile/en-US/?user=CraigMucklestonAddhandler with a DelegateI came across a snippet of C# code which is very useful. I am trying to convert it to VB.NET, but can't seem to.<br/><br/><br/>timer.Tick += delegate { panel.Children.Add(source); timer.Stop(); };<br/><br/>Is it possible to translate this to something similar in VB?<br/>Mon, 23 Nov 2009 16:43:53 Z2009-11-23T22:41:20Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/8342b06e-b598-462c-b2d5-bf9ac3d05aefhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/8342b06e-b598-462c-b2d5-bf9ac3d05aefsocox11http://social.msdn.microsoft.com/Profile/en-US/?user=socox11txt duplicates x-times in labelHi all, <div><br/></div> <div>I want to write &quot;ab&quot; x-times in label. x is defined in the txt box, it can be any integer.</div> <div><br/></div> <div>So when I enter: X=10 result must be &quot;abababababababababab&quot; , how to do this?</div> <div><br/></div> <div>thx</div>Mon, 23 Nov 2009 15:07:34 Z2009-11-23T21:05:31Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/55f22d71-44ae-4b68-b448-9c29241bebc9http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/55f22d71-44ae-4b68-b448-9c29241bebc9azdonaldhttp://social.msdn.microsoft.com/Profile/en-US/?user=azdonaldHelp with WinwedgePlease has anyone worked with winwedge? I need to use it for a project  i have to deliver on thursday.  <div>Thanks.</div>Mon, 23 Nov 2009 08:03:28 Z2009-11-23T20:09:02Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/ac3c8137-2fa4-4ee8-b775-97dceaed7372http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/ac3c8137-2fa4-4ee8-b775-97dceaed7372mayuresh_kshirsagarhttp://social.msdn.microsoft.com/Profile/en-US/?user=mayuresh_kshirsagarHow to I get and set value of Local Group Policy Editor using vb scriptsI want to be able to get and set values of Local Policy Editor using vb scripts (or for that matter any other command line thing). The problem is that for my requirement I cannot rely on the machine in question having anything like powershell. I want to be able to run a script/command and get/set the values of things inside Local Group Policy Editor.<br/> <br/> eg. I want to be able to set things like running gpedit.msc and set the value for &quot;\\Computer Configuration\Administrative Templates\Network\Offline Files\Default Cache Size&quot;, and I want to do this without manual intervention.<br/> <br/> vb script was my obvious choice thinking that this must be possible using it, however I dont know where to start at. However if you have pointers regarding this, or any other way through which I can achieve this usecase please educate me.<br/> <br/> Thanks,<br/> MayureshThu, 19 Nov 2009 14:17:50 Z2009-11-23T11:40:43Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/6d3b3fdf-c15a-49e3-9a87-802df4e3a155http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/6d3b3fdf-c15a-49e3-9a87-802df4e3a155Mheanhttp://social.msdn.microsoft.com/Profile/en-US/?user=MheanHelp Please... How to insert audio?Help Please... How to insert audio?Sun, 22 Nov 2009 16:18:32 Z2009-11-25T14:59:18Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/1f04b243-a315-48b8-b1a6-70a7970fada4http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/1f04b243-a315-48b8-b1a6-70a7970fada4Khaled El-Tabiehttp://social.msdn.microsoft.com/Profile/en-US/?user=Khaled%20El-TabieHow Can I Change ToolTip to RightToLeftPlase How :<br/>1- How Can I Change ToolTip to RightToLeft ?<br/>2- How Can I Save Sitting in The Same Folder Of My Applocation ?<br/>I think that :<br/>    User Sitting Reset to it's default When the user copy or move the application from folder to other <br/>    App. Sitting ReadOnly i can't save it when the user change it<br/>so what is the solution ?<br/>I'm Using VS2005 - VBSat, 21 Nov 2009 17:40:57 Z2009-11-23T07:06:27Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/6d96cb2c-7623-4427-88c8-d5ba8d3bb4b5http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/6d96cb2c-7623-4427-88c8-d5ba8d3bb4b5taciturnonehttp://social.msdn.microsoft.com/Profile/en-US/?user=taciturnoneHow to use VB to update multiple tables I have a database with numerous tables all containing the same field.  the field needs to have the same value in all of the tables, but currently  doesn't.<br/><br/>Is there a way to use Visual basic code that goes to each table and updates the field in all of the tables without having to manually go to each table and update the field?<br/><br/>thanksFri, 20 Nov 2009 03:11:50 Z2009-11-24T08:44:09Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/7f179d96-50a3-4ec4-bc66-5f57a8e75585http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/7f179d96-50a3-4ec4-bc66-5f57a8e75585Mheanhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mheanpls help.. how to save text from textbox to microsoft word??<strong>pls help.. how to save text from val(textbox) and picturebox into microsoft word??<br/></strong>Thu, 19 Nov 2009 15:28:44 Z2009-11-24T08:43:01Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/9533121f-9718-4ac1-b40c-022c09da0508http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/9533121f-9718-4ac1-b40c-022c09da0508Mheanhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mheanto: Mr. John Anthony Oliverhi JOhn,<br/><br/>do u know how to draw a right triangle and spherical triangle using vb.net 2008?????<br/><br/>where you're going to consider the angles and sides of the traingles.......<br/><br/>thanx...and hope for your answer... :)Thu, 12 Nov 2009 10:38:56 Z2009-11-22T21:49:47Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/28d812bb-5f33-46d6-94dd-6a2d1f442a29http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/28d812bb-5f33-46d6-94dd-6a2d1f442a29KurtRRyanhttp://social.msdn.microsoft.com/Profile/en-US/?user=KurtRRyandisplaying errortext on the current cell in DataGridView control<p align=left><font face=Arial size=2>I'm trying to use the errortext field on a cell to display a validation error.  It works fine if I leave the cell, but I can't figure out how to display it while staying in the cell.  I have seen examples where the code updates the row's errortext, but I really want to mark the cell in error.  Is this possible? </font></p> <p align=left><font face=Arial size=2> </p></font> <p align=left><font face=Arial size=2>My code is:<br><br><font size=2></p> <p align=left></font><font color="#0000ff" size=2> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Block</span></div> <p align=left><font color="#0000ff" size=2>Private</font><font size=2> </font><font color="#0000ff" size=2>Sub</font><font size=2> dg_CellValidating(</font><font color="#0000ff" size=2>ByVal</font><font size=2> sender </font><font color="#0000ff" size=2>As</font><font size=2> System.Object, </font><font color="#0000ff" size=2>ByVal</font><font size=2> e </font><font color="#0000ff" size=2>As</font><font size=2> System.Windows.Forms.DataGridViewCellValidatingEventArgs) </font><font color="#0000ff" size=2>Handles</font><font size=2> dg.CellValidating</p> <p align=left></font><font color="#008000" size=2> </p></font><font size=2> <p align=left></font><font color="#0000ff" size=2>Dim</font><font size=2> val </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>String</font><font size=2> = e.FormattedValue.ToString</font></p> <p align=left>Dim dgv as DataGridView = Ctype(sender, DataGridView)</p> <p align=left>Dim cell as DataGridViewCell = dgv.rows(e.RowIndex).Cells(e.ColumnIndex)</p> <p align=left> </p><font size=2> <p align=left></font><font color="#0000ff" size=2>  If</font><font size=2> </font><font size=2>val = </font><font color="#a31515" size=2>&quot;X&quot;</font><font size=2> </font><font color="#0000ff" size=2>Then</p></font><font size=2> <p align=left></font><font color="#0000ff" size=2>    </font><font size=2>cell.ErrorText = </font><font color="#a31515" size=2>&quot;Just a test&quot;</p></font> <p align=left>    dgv.invalidateCell(cell)        'an attempt to repaint the cell<font size=2></p></font><font size=2> <p align=left>    e.Cancel = </font><font color="#0000ff" size=2>True</p></font><font size=2> <p align=left></font><font color="#0000ff" size=2>  End</font><font size=2> </font><font color="#0000ff" size=2>If</p></font><font size=2> <p align=left></font><font color="#0000ff" size=2></font> </p> <p align=left><font color="#0000ff" size=2>End</font><font size=2> </font><font color="#0000ff" size=2>Sub</font></p> <p align=left> </p></div></div> <p align=left> </p></font> <p></p> <p align=left><font color="#0000ff" size=2></p> <p>Any help would be appreciated.</p> <p align=left> </p> <p align=left>Kurt</p> <p align=left></font></font> </p>Tue, 09 Oct 2007 20:04:43 Z2009-11-22T18:10:07Zhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/029a87ae-afb6-4652-84c9-7d4e89d52a7bhttp://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/029a87ae-afb6-4652-84c9-7d4e89d52a7bCapsolhttp://social.msdn.microsoft.com/Profile/en-US/?user=CapsolHelp for newbie with Data AccessI am trying to connect to a SQL DB and loop through some tables.  My tables are linked on the EMPLOYID field between UPR00100 and UPR00102.  I want to write data as follows:<br><br>Level1,EMPLOYID,EmpName (from UPR00100)<br>Level4,EMPLOYID,Address1,Address2,etc.. (from UPR00102)<br><br>Here is my data access code... I don't know how to code the loop.  I know how to do it in SQL using a cursor but not VB 2005<br><br><font color="#0000ff" size=2> <p>Option</font> <font color="#0000ff" size=2>Explicit</font> <font color="#0000ff" size=2>On</p> <p>Option</font> <font color="#0000ff" size=2>Strict</font> <font color="#0000ff" size=2>On</p> <p>Imports</font><font size=2> System.Data</p></font><font color="#0000ff" size=2> <p>Imports</font><font size=2> system.Data.SqlClient</p></font><font color="#0000ff" size=2> <p>Module</font><font size=2> Module1</p> <p></font><font color="#0000ff" size=2>Public</font> <font color="#0000ff" size=2>Class</font><font size=2> DataSet1</p> <p></font><font color="#0000ff" size=2>Public</font> <font color="#0000ff" size=2>Shared</font> <font color="#0000ff" size=2>Sub</font><font size=2> Main()</p> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> connectionString </font><font color="#0000ff" size=2>As</font> <font color="#0000ff" size=2>String</font><font size=2> = _</p> <p>GetConnectionString()</p> <p>ConnectToData(connectionString)</p> <p></font><font color="#0000ff" size=2>End</font> <font color="#0000ff" size=2>Sub</p></font><font size=2> <p></font><font color="#0000ff" size=2>Private</font> <font color="#0000ff" size=2>Shared</font> <font color="#0000ff" size=2>Sub</font><font size=2> ConnectToData( _</p> <p></font><font color="#0000ff" size=2>ByVal</font><font size=2> connectionString </font><font color="#0000ff" size=2>As</font> <font color="#0000ff" size=2>String</font><font size=2>)</p> <p></font><font color="#008000" size=2>' Create a SqlConnection to the Northwind database.</p></font><font size=2> <p></font><font color="#0000ff" size=2>Using</font><font size=2> connection </font><font color="#0000ff" size=2>As</font><font size=2> SqlConnection = </font><font color="#0000ff" size=2>New</font><font size=2> SqlConnection( _</p> <p>connectionString)</p> <p></font><font color="#008000" size=2>' Create a SqlDataAdapter for the Suppliers table.</p></font><font size=2> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> EmployeesAdapter </font><font color="#0000ff" size=2>As</font><font size=2> SqlDataAdapter = _</p> <p></font><font color="#0000ff" size=2>New</font><font size=2> SqlDataAdapter()</p> <p></font><font color="#008000" size=2>' A table mapping names the DataTable.</p></font><font size=2> <p>EmployeesAdapter.TableMappings.Add(</font><font color="#a31515" size=2>&quot;Table&quot;</font><font size=2>, </font><font color="#a31515" size=2>&quot;UPR00100&quot;</font><font size=2>)</p> <p></font><font color="#008000" size=2>' Open the connection.</p></font><font size=2> <p>connection.Open()</p> <p>Console.WriteLine(</font><font color="#a31515" size=2>&quot;The SqlConnection is open.&quot;</font><font size=2>)</p> <p></font><font color="#008000" size=2>' Create a SqlCommand to retrieve Suppliers data.</p></font><font size=2> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> EmployeesCommand </font><font color="#0000ff" size=2>As</font><font size=2> SqlCommand = </font><font color="#0000ff" size=2>New</font><font size=2> SqlCommand( _</p> <p></font><font color="#a31515" size=2>&quot;SELECT * FROM dbo.UPR00100;&quot;</font><font size=2>, _</p> <p>connection)</p> <p>EmployeesCommand.CommandType = CommandType.Text</p> <p></font><font color="#008000" size=2>' Set the SqlDataAdapter's SelectCommand.</p></font><font size=2> <p>EmployeesAdapter.SelectCommand = EmployeesCommand</p> <p></font><font color="#008000" size=2>' Fill the DataSet.</p></font><font size=2> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> dataSet </font><font color="#0000ff" size=2>As</font><font size=2> DataSet = </font><font color="#0000ff" size=2>New</font><font size=2> DataSet(</font><font color="#a31515" size=2>&quot;Employees&quot;</font><font size=2>)</p> <p>EmployeesAdapter.Fill(dataSet)</p> <p></font><font color="#008000" size=2>' Create a second SqlDataAdapter and SqlCommand to get</p></font><font size=2> <p></font><font color="#008000" size=2>' the Products table, a child table of Suppliers. </p></font><font size=2> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> EmpAddressAdapter </font><font color="#0000ff" size=2>As</font><font size=2> SqlDataAdapter = _</p> <p></font><font color="#0000ff" size=2>New</font><font size=2> SqlDataAdapter()</p> <p>EmpAddressAdapter.TableMappings.Add(</font><font color="#a31515" size=2>&quot;Table&quot;</font><font size=2>, </font><font color="#a31515" size=2>&quot;UPR00102&quot;</font><font size=2>)</p> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> EmpAddressCommand </font><font color="#0000ff" size=2>As</font><font size=2> SqlCommand = </font><font color="#0000ff" size=2>New</font><font size=2> SqlCommand( _</p> <p></font><font color="#a31515" size=2>&quot;SELECT * FROM dbo.UPR00102;&quot;</font><font size=2>, _</p> <p>connection)</p> <p>EmpAddressAdapter.SelectCommand = EmpAddressCommand</p> <p></font><font color="#008000" size=2>' Fill the DataSet.</p></font><font size=2> <p>EmpAddressAdapter.Fill(dataSet)</p> <p></font><font color="#008000" size=2>' Close the connection.</p></font><font size=2> <p>connection.Close()</p> <p>Console.WriteLine(</font><font color="#a31515" size=2>&quot;The SqlConnection is closed.&quot;</font><font size=2>)</p> <p></font><font color="#008000" size=2>' Create a DataRelation to link the two tables</p></font><font size=2> <p></font><font color="#008000" size=2>' based on the SupplierID.</p></font><font size=2> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> parentColumn </font><font color="#0000ff" size=2>As</font><font size=2> DataColumn = _</p> <p>dataSet.Tables(</font><font color="#a31515" size=2>&quot;UPR00100&quot;</font><font size=2>).Columns(</font><font color="#a31515" size=2>&quot;EMPLOYID&quot;</font><font size=2>)</p> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> childColumn </font><font color="#0000ff" size=2>As</font><font size=2> DataColumn = _</p> <p>dataSet.Tables(</font><font color="#a31515" size=2>&quot;UPR00102&quot;</font><font size=2>).Columns(</font><font color="#a31515" size=2>&quot;EMPLOYID&quot;</font><font size=2>)</p> <p></font><font color="#0000ff" size=2>Dim</font><font size=2> relation </font><font color="#0000ff" size=2>As</font><font size=2> DataRelation = </font><font color="#0000ff" size=2>New</font><font size=2> _</p> <p>System.Data.DataRelation(</font><font color="#a31515" size=2>&quot;EmployeeAddresses&quot;</font><font size=2>, _</p> <p>parentColumn, childColumn)</p> <p>dataSet.Relations.Add(relation)</p><br><br> <p>Console.WriteLine( _</p> <p></font><font color="#a31515" size=2>&quot;The {0 DataRelation has been created.&quot;</font><font size=2>, _</p> <p>relation.RelationName)</p> <p></font><font color="#0000ff" size=2>End</font> <font color="#0000ff" size=2>Using</p></font><font size=2> <p></font><font color="#0000ff" size=2>End</font> <font color="#0000ff" size=2>Sub</p></font><font size=2> <p></font><font color="#0000ff" size=2>Private</font> <font color="#0000ff" size=2>Shared</font> <font color="#0000ff" size=2>Function</font><font size=2> GetConnectionString() </font><font color="#0000ff" size=2>As</font> <font color="#0000ff" size=2>String</p></font><font size=2> <p></font><font color="#008000" size=2>' To avoid storing the connection string in your code, </p></font><font size=2> <p></font><font color="#008000" size=2>' you can retrieve it from a configuration file.</p></font><font size=2> <p></font><font color="#0000ff" size=2>Return</font> <font color="#a31515" size=2>&quot;Data Source=Portal;Initial Catalog=CAPT;&quot;</font><font size=2> _</p> <p>&amp; </font><font color="#a31515" size=2>&quot;Integrated Security=SSPI;&quot;</p></font><font size=2> <p></font><font color="#0000ff" size=2>End</font> <font color="#0000ff" size=2>Function</p></font><font size=2> <p></font><font color="#0000ff" size=2>End</font> <font color="#0000ff" size=2>Class</p> <p>End</font> <font color="#0000ff" size=2>Module<br><br>What am I missing?</p></font>Thu, 09 Oct 2008 00:44:56 Z2009-11-22T18:06:10Z