646 Posted Topics
Re: You can sort three numbers without an array. But your prof/teacher may have wanted an array-based solution. So put those numbers in an array and you have a solution which can easily handle also four integer's sorting . VB.NET arrays have a Sort-method: Array.Sort(MyIntArr) which sorts your array in ascending … | |
Re: [ICODE]myPath = HttpContext.Current.Server.MapPath("somePath");[/ICODE] and remember to add reference to [ICODE]System.Web[/ICODE] | |
Re: There are two ways to do it. First is to wait [CODE=VB.NET]copyProcess.Start("C:\Program Files\Internet Explorer\iediagcmd.exe") copyProcess.WaitForExit(10000) ' Wait until finished or timeout after ten secs[/CODE] for the process to exit. Second is to wait event which a process raises when finished: [CODE=VB.NET]Private WithEvents copyProcess As Process ' Declare process ' Event … | |
Re: Back to the OP's question. If I do remember right, Explorer won't let you open C:\Users\NN folder unless you're NN. It's a good programming practice not to ask user to have admin rights for your app. It's totally waste of time because standard users do not know admin password and … | |
Re: You have code outside class and ... quite a few other errors [CODE=C#] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Problem8Pg179 { public class GranolaSales { public static void Main() { const int NUMBER_OF_BARS = 12; const double NUMBER_OF_CASES = 5; const double ASSOCIATION_FEES = 0.10; string inputValue; … | |
Re: You can use built-in Sort method [CODE=C#]// Declare an array with ten elements //int[] a = new int[20]; int[] a = new int[10]; Random rand = new Random(); for (int i = 0; i < 10; i++) a[i] = rand.Next(10000); for (int i = 0; i < 10; i++) Console.WriteLine(a[i]); … | |
Re: Here's a tip: Show wait cursor: [CODE]Me.Cursor = Cursors.WaitCursor[/CODE] and after the work is done return it to normal: [CODE]Me.Cursor = Cursors.Default[/CODE] If you have a statusbar in your form you may display text: "Loading..." or something like that. And the most important thing. If you have some long lasting … | |
Re: I didn't quite get that. Is it this you're trying to do: [CODE=VB.NET]With ProgressBar1 .Value = 50 End With With ProgressBar2 .Value = 50 End With[/CODE]to get into [CODE]With Each ProgressBar .Value = 50 End With Each[/CODE] | |
Re: How do you handle those diacritics or glyphs? As a Latin letters or some other way (like images)? I mean what kind of keyboard you use to write Maldivian? If Maldivian glyphs can be represented as Latin letters (just like Cyrillic letters can be represent), it shouldn't be hard to … | |
Re: I've used only classic ASP and it had session variables. If asp.NET has similar method, the first thing in secure.aspx page is to check that "session variable". If it's set, let the user continue. If it's not set or not found, use page transfer to move user back to start … | |
Re: [QUOTE]to keep the MouseLeave event on the panel from firing when another control is crossed? Or another way to accomplish the same?[/QUOTE] You can't prevent that event. But instead of mouse leaving the panel, you should think where the mouse enters. I would assume that the mouse enters a form. … | |
Re: [QUOTE]the progressbar starts to load until and stops only when process.HasExited[/QUOTE] Process object doesn't raise any events except Exited. So there's no way to know what the process is doing. What sort of process you're dealing with? | |
Re: Could you please post that part of the code that uses StringBuilder? | |
Re: With nested controls you must be aware which Controls collection you're dealing with. Also, Panel control doesn't support foreach syntax so you have to use for-loop [CODE=C#]Control c; for (int i=0; i<pnlDeadPcs.Controls.Count; i++) { c = pnlDeadPcs.Controls[i]; if (c is Button) { // Use Button c } } [/CODE] HTH | |
Re: No. There's not such thing. But you can use Node's Tag property to store extra information [CODE=VB.NET]Dim thisRoot As New TreeNode thisRoot.Tag = "C:\users\myname\My Documents\" . . . Dim rootPath As String rootPath = thisRoot.Tag.ToString()[/CODE] HTH | |
Re: IMHO the first place to get information is [URL="http://msdn.microsoft.com/en-us/library/w0x726c2.aspx"]MSDN[/URL]. In your case especially [URL="http://msdn.microsoft.com/en-us/library/system.io.aspx"]System.IO Namespace[/URL] and [URL="http://msdn.microsoft.com/en-us/library/system.net.aspx"]System.Net Namespace[/URL]. MSDN is a reference or a documentation of the .NET Framework and not a tutorial but if you're familiar with programming you should find all you need from there. HTH | |
Re: You should have a different SQL clause depending on your search box. Procedure LoadPeople should start like this [CODE=VB.NET]Dim sqlQuery As String Select Case ComboBox1.SelectedValue.ToString() Case "Name" sqlQuery = "SELECT * FROM reservation ORDER BY Name" Case "Room type" sqlQuery = "SELECT * FROM reservation GROUP BY RoomType" End Select[/CODE]Since … | |
Re: Use [CODE=C#]Application.DoEvents();[/CODE] before calling [ICODE]Thread.Sleep()[/ICODE] HTH | |
Re: That's because "eng" and "type" are attributes, not elements. Here's a bit fixed version: [CODE=VB.NET] Dim settings As XmlWriterSettings = New XmlWriterSettings() Dim writer As XmlWriter Dim i As Integer ' i was undeclared variable settings.Indent = True writer = XmlWriter.Create("D:\Translations", settings) ' Begin writing. writer.WriteStartDocument() ' Start tag for … | |
Re: Have you tried this basic way to do it? [CODE=VB.NET]' Add some items ContextMenuStrip1.Items.Add("First") ContextMenuStrip1.Items.Add("Second") ContextMenuStrip1.Items.Add("Third")[/CODE] and when you handle the ItemClicked event: [CODE=VB.NET]Private Sub ContextMenuStrip1_ItemClicked(sender As Object, e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuStrip1.ItemClicked Select Case e.ClickedItem.ToString() Case "First" ' Item with text "First" selected Case "Second" ' Item with text … | |
Re: There are pretty good examples in Microsoft's [URL="http://social.msdn.microsoft.com/Forums/en/Vsexpressvb/thread/72b5a038-912d-4455-929d-89eeb9984d7c"]MSDN site[/URL] about printing with .NET. CodeProject has this [URL="http://www.codeproject.com/KB/printing/MCLFormPrintControl.aspx"]Form Print Control[/URL] custom control for printing. I believe that you'll find either one as an easy to use solution. HTH | |
Re: [QUOTE]"No of query values and destination fields are not the same"[/QUOTE] That's a very clear error statement. Did you check that your fields and values do match in SQL statement? You're storing everything as a string. Does your data contain apostrophe (') somewhere? If it does you have to replace … | |
Re: Add the user name and the password at the same time: [CODE=VB.NET]Dim AdUsr As String Dim AdPW As String AdUsr = UsrAdd.Text AdPW = PasswordAdd.Text ' Replace with correct textbox name AdUsr = AdUsr.Replace("'", "''") AdPW = AdPW.Replace("'", "''") ' If you allow apostrophe in the password Dim CommandUser As … | |
Re: [QUOTE]my code can do that except when row and col are the same number. How can I fix that?[/QUOTE] Line 9: [ICODE]if (j + 1 == col)[/ICODE] [QUOTE]how can I store these values into a 2D array[/QUOTE] Add declaration: [ICODE]int[,] puzzle = new int[row, col];[/ICODE] Then add a new line … | |
Re: Could you use a second table (YearTable) to hold year and count information: [CODE]YearCode YearCount 2009 1 2010 2 [/CODE] Now you could [ICODE]SELECT MAX(YearCount) AS YearVal FROM YearTable WHERE YearCode = 2010[/ICODE] Also [ICODE]SELECT MAX(YearCount) AS YearVal FROM YearTable WHERE YearCode = 2011[/ICODE] would return YearVal = DbNull. If … | |
Re: You can use InputBox :D Ok, trap some key event in form level: KeyPress, KeyDown or KeyUp. KeyDown or KeyUp might be most flexible choices. HTH | |
Re: I think that line [ICODE]FullTypeName = Application.ProductName & "." & FormName[/ICODE] goes wrong because you use Application.ProductName which is "SQLtesting". Instead of that you should reference to assembly: [CODE=VB.NET]Imports System.Reflection Dim assemblyName As String = "<here's the name of your other assembly>" Dim oAssembly As Assembly = Nothing ' the … ![]() | |
Re: You could just try yourself if it can be done... Anyway, here's my test: [CODE=VB.NET]Dim newItem As ListViewItem ' Create sub item newItem = New ListViewItem newItem.SubItems.Add("first") ' Add one lv-item with one sub item ListView1.Items.Add(newItem) ' Show the value MessageBox.Show("ListView1[0,1] = " & ListView1.Items(0).SubItems(1).ToString()) ' Second listview ' Create … | |
Re: VS2010 has C# just like previous VS versions have had. The same should be with Student Edition. Mine is free Express Edition and it has VB, C#, C++ and WebDev. Check that you have installed all components from the DVD disk and the installation folder has a "Microsoft Visual C# … | |
Re: You can try [URL="http://www.developerfusion.com/tools/convert/csharp-to-vb/"]Convert C# to VB.NET[/URL]. You can't convert a whole project at once. You have to build VB.NET version a piece by piece. HTH | |
Re: [QUOTE]i have a little filesystem in my program[/QUOTE] If you use your own filesystem [U]and[/U] you don't need any Explorer integration, I would suggest using a new table or some hidden extra file with filenames and their explanations. The second approach may be much harder to program: use alternate data … | |
Re: This might be correct way to do it [CODE=VB.NET] Dim newItem As ListViewItem ' Start with four sub items newItem = New ListViewItem(New String() {"First", "Second", "Third"}) ListView1.Items.Add(newItem) ' Now add the fourth sub item ListView1.Items(0).SubItems.Add("Fourth")[/CODE] HTH | |
Re: [QUOTE]i searched little but i just can find copying strings[/QUOTE] That's exactly how file copy works! Open Explorer, select a file or few and try this code [CODE=VB.NET]If Clipboard.ContainsFileDropList() Then For Each fn As String In Clipboard.GetFileDropList() MessageBox.Show(fn) Next End If[/CODE] HTH | |
Re: You can easily loop all your form's controls [CODE=VB.NET]' Put this code in the form (Me refers to (your) form now) Dim thisButtonName As String = "Button1" ' This is the name of the button you're looking for Dim isButtonVisible As Boolean = True ' This is the "visibility" value … | |
Re: Here's how you get your row to variables: [CODE=C#]string firstName; string lastName; bool membership; DateTime cardDate; // Add first row dataGridView1.Rows.Add(); // Add some test data to 1st row dataGridView1.Rows[0].Cells[0].Value = "John"; dataGridView1.Rows[0].Cells[1].Value = "Doe"; dataGridView1.Rows[0].Cells[2].Value = true; dataGridView1.Rows[0].Cells[3].Value = DateTime.Now; // Get data from 1st row firstName = dataGridView1.Rows[0].Cells[0].Value.ToString(); … | |
Re: I hope you get things started with this little snippet [CODE=VB.NET]Dim cmdProcess As Process cmdProcess = New Process() ' Dump all info from ipconfig command cmdProcess.StartInfo.Arguments = "/ALL" ' Run command: ipconfig cmdProcess.StartInfo.FileName = "ipconfig" ' Redirect stdout cmdProcess.StartInfo.RedirectStandardOutput = True ' Set to false, otherwise you can't redirect stdout … | |
Re: [CODE=VB.NET]Dim isItTime As Boolean = False Dim aDateFromReminder As DateTime = CDate("14.9.2011 7:00") ' This date comes from the reminder. I have to use Finnish datetime format Dim timeInterval As Integer = 48 ' How much earlier you need to be reminded, the unit is hours ' Compare the reminder's … | |
Re: [QUOTE]how to transfer that user input in these text boxes[/QUOTE] Pass them in the URL. Here's a simple code with a nice Finnish twist [CODE=C#]double latitude = 0; // textBox1.Text double longitude = 0; // textBox2.Text string strURL = ""; bool isValidCoordinate = false; // use a flag to indicate … | |
Re: Relative to what? I guess relative to your application. To be more precise, relative to the [U]current directory[/U]. Here's the code: [CODE=VB.NET]Dim FileName As String ' File is two levels up from the current directory FileName = "..\..\test.txt" ' Test if the file really exists If My.Computer.FileSystem.FileExists(FileName) Then ' Dump … | |
Re: [QUOTE]what should i write in the "InlineAssignHelper" function?[/QUOTE] Nothing. Don't use it. [CODE=C#]int arg1; int expr1 = arg1 = 16;[/CODE]is a very stupid way to set initial values to variables. It's the same as: [CODE=C#]int arg1 = 16; int expr1 = 16;[/CODE]and now the code is trivial to translate: [CODE=VB.NET]Dim … | |
Re: First, use type casting when you convert text to number: [ICODE]dblYard = CDbl(txtYard.Text)[/ICODE] There are quite a few ways to format doubles as strings. But [ICODE]txtCost.Text = Format(dblCostA, 2)[/ICODE] is not syntactically correct (the latter parameter should be a string). You should use FormatNumber function instead. Anyway, here's some formatting … | |
Re: I suggest comparing checksums of the original file and the possibly corrupted file. Resulting hash values are easy to store and you can validate corrupted file even without the original file. .NET has a few suitable hash functions like SHA1 and SHA256 (see System.Security.Cryptography namespace). CRC32 is not provided but … | |
Re: Read first [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]this[/URL]. Especially the part which says: [QUOTE]"Do provide evidence of having done some work yourself if posting questions from school or work assignments"[/QUOTE]. | |
Re: You have to scale the image. The code below gets an image from the file and rescales its size down to fit in the PictureBox. [CODE=VB.NET] ' See http://www.vb-helper.com/howto_net_image_resize.html for the original code Dim PicBoxHeight As Integer Dim PicBoxWidth As Integer Dim ImageHeight As Integer Dim ImageWidth As Integer Dim … | |
Re: Use dictionary collection: [CODE=Csharp]// Dictionary, key is number from the list and the associated value is the number of times the key is found Dictionary<int, int> occurrences = new Dictionary<int, int>(); int[] test = new int[] { 1, 1, 1, 2, 2, 3, 4, 5, 6 }; // Debug data … | |
Re: You could use form's owner property. Calling Form99 would be [CODE=VB.NET]Form1 Form99.Show(Me) ' Me i.e. owner is now Form1 Form2 Form99.Show(Me) ' Me i.e. owner is now Form2[/CODE] To find out who's the caller (i.e. owner), read the owner property: [CODE=VB.NET]Private Sub Form99_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) … | |
Re: To read an image from the file to a picturebox control: [CODE=VB.NET]Me.PictureBox1.Image = Image.FromFile("C:\Temp\somepicture.jpg")[/CODE] I [U]guess[/U] that's what you were looking for. And remember to read codeorder's comment about your question... | |
Re: [QUOTE]I am going to write a program which can calculate MD5 of a file even the file is in use[/QUOTE] if a file "is in use" means that someone has an exclusive lock to the file i.e. no one else can access the file until the lock's owner releases the … | |
Re: And here's my VB.NET blog post "[URL="http://windevblog.blogspot.com/2008/08/convert-image-to-byte-array-and-vice.html"]Convert image to byte array and vice versa[/URL]" back from 2008. It has some additional comments to consider also with the C# version above. |
The End.