1,857 Posted Topics
Re: Your code doesn't follow the description. You got 8 functions besides Main and none of them take any parameters, let alone any arrays. I would suggest using a class to represent a player. This allows you to have one function that accepts a player object and the board array as … | |
Re: array1 and array 2 are declared as int. This means that you are overwriting the values in them and the last loop is re-using the last value stored in them. Without a clear idea of the desired outcome it's hard to arrive at a solution. | |
Re: It looks to me that instead of adding 100000 you should probably use the value of I and add 100001 For Each row As DataGridViewRow In DataGridView1.Rows Dim obj(row.Cells.Count - 1) As Object For i = 0 To row.Cells.Count - 1 obj(i) = i + 100001 Next Me.DataGridView3.Rows.Add((obj)) Next This … | |
Re: There are 2 main ways of doing this. Line by line conversion by hand Third party conversion tool. A search term such as `convert vb to c#` produces lots of hits in Google. | |
Re: In order top use an array effectively, you would need to make each pizza an object. This will require a custom class. Something like this: class Pizza { public: struct Item { string item = ""; int cost = 0; } Pizza(Item _size, Item _crust, Item _flavor, vector<Item> _extras); int … | |
Re: Your basic algorithm seems sound. Your problem with getting the correct answer could have something to do with how the site giving you the problem is expecting you to receive the data. A couple of things, though: The bounds checks are unnecessary, since the problem description guarantees the numbers will … | |
Re: Usually these types of errors mean you have to qualify which namespace the property/method belongs to. | |
Re: One way to do this is with the [Microsoft Magnificiation API](https://msdn.microsoft.com/en-us/library/windows/desktop/ms692402%28v=vs.85%29.aspx) | |
Re: One of the problems with your existing code, is you're trying to access the pointers without allocating memory for them: template <class T> void matrixType<T>::initialize(T row1, T col1) { rawMatrix1 = new T*[row1]; for (int a = 0; a < row1; a++) { rawMatrix1[a] = new T[col1]; std::cout << "enter … | |
Re: If you're printing a registration form, you probably don't want any of the extra stuff, like the control box or any buttons, to be printed. Something like this might work: Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'make any controls you don't want printed invisible … | |
Re: It looks to me that the query is loking to compare numbers but you're giving it a string. Try converting the subitem value to a number and calling the query with that. | |
Re: It looks to me that you need to read the file inside the while loop: while(infile.read(reinterpret_cast<char*>(&t1),sizeof(teacher))) { if(t1.getcnicno()!=check) { outfile.write(reinterpret_cast<char*>(&t1),sizeof(teacher)); } } Also checking for eof is not a reliable way of terminating the loop. Using the return value of read is more reliable. | |
Re: The class for the table is called DataTable. The columns are called DataColumns and the rows with data are DataRows. These classes are present by default in a vb.net form applcation. The basic steps to add data to the data table are: * Instantiate a new DataTable * Add the … | |
Re: Somehow your original post got duplicated. My answer is in the other post. If your question is answered please remember to mark them solved. Thanks | |
Re: It looks to me that your problem is in the destructor for Toll Administrator. You're trying to delete arrays that haven't been allocated with the new operator. Since you seem to want to delete items from the arrays, making them dunamic, you might be better off using vectors instead, which … | |
Re: It appears to me that one or more fields in one or more rows is empty, which is throwing the cast exception. Try using the `Is` operator instead of `=`: If dr(0) Is txtuname.Text AndAlso dr(1) Is txtpw.Text AndAlso dr(2) Is MetroComboBox1.Text Then On a side note, using `AndAlso` allows … | |
Re: It looks like you need to use the `AppendText` method of the TextBox class: foreach(string line in File.ReadAllLines(comboBox1.Text)) { textBox1.AppendText(line.Split(',')[0]+"\n"); } | |
Re: From an examination of your code, a part of your problem appears to be using `index` to fill the array, but your loop is incrementing `count`. Therefore the array is always using the same index. Also using `eof()` to terminate the loop is bad practise. Instead use the return value … | |
Re: The classes involved are OpenFileDialog and SaveFileDialog. Basically instantiate a new instance of each class and use the `ShowDialog()` method to show it. The `Filename` property contains the filename opened, or saved. | |
Re: Actually you can do that all you need is a button(to signify when the typing is done) and a handler for its click event: Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click If ComboBox1.Text <> "" AndAlso Not ComboBox1.Items.Contains(ComboBox1.Text) Then ComboBox1.Items.Add(ComboBox1.Text) ComboBox1.ResetText() End If End Sub | |
Re: It would help to know why you're using 2 decks. Part of your problem might be linked to duplicating your code in several places. If you pass the address of the deck to the displaydeck function you only need code to deal with the deck that's passed. Also this means … | |
Re: One way is to create a function,that returns a boolean, for each validation step. If each step is true the password is valid. This way you can concecntrate on each step and get it right before moving on. | |
Re: There are great many option to accomplish this. One way, that doesn't require explicitly creating an extra array, is to use the Lines property of the RichTextBox, which is a string array already. The RichTextBox seems to like adding extra blank lines at the end, so before sorting, you'll need … | |
Re: What language are you using? What code have you tried? | |
Re: OK, you're getting there. You've got a description of your goal. You've got the code you've developed so far. Now we need a description of the problem(s) in your code that you have trouble fixing. | |
Re: One way is to use a public method that uses the Add method of the List class: void AddOrderLine(OrderLine newOrderLine) { OrderLines.Add(newOrderLine) } I would suggest keeping the list private instead of public. This way you choose which methods the user can use to interact with the list and eliminates … | |
Re: The application is in the folder you specified when you published it. The default folder is in the project folder. However, it is not an exe file. It is a .application file. The description should say ClickOnce Application. There should also be a shortcut in the Start Menu, with the … | |
Re: One way would be with a custom class to represent the collection. Use a vector as the base collection, then overload the index operator to accept a negative value and offset it to find the correct positive value in the base collection. Here's what such a class might look like: … | |
![]() | Re: If your xaml code has `State Triggers` the same as your post, remove the space, `StateTriggers`. ![]() |
Re: It looks to me you might need some custom classes. One to represent the data for each record and also a class that controls a collection of that data: #include <iostream> #include <string> #include <vector> using std::string; using std::ostream; using std::istream; using std::vector; class DataCollection { private: class Data { … | |
Re: One possible cause is, your query isn't returning any data. | |
Re: It should be OK to use it the same as in the actual function block: int findMobile( string word, int dir[] ); | |
Re: One option would be to just disable the controls on the MDIParent. First set the MDIParent property insted of the Owner property. Second add a static method to enable/disable the controls: public static void EnableControls(Form thisForm, bool enable = true) { if (thisForm.IsMdiContainer) { foreach (Control c in thisForm.Controls) { … | |
Re: A couple things I've noticed: * You're loading the listboxes with the whole path. This makes finding the duplicates problematic at best. * You're duplicating the code to load the listboxes. A method taking the listbox as an argument will simplify this. Since you're loading file names and directory names, … | |
Re: Try setting the value of the DateTimePicker by converting the cell value to a Date value dtpAppointmentdate.Value = Convert.ToDateTime(row.Cells["Appointment Date"].Value) | |
Re: I would say, for while loops, that it depends on the trigger(s) needed to break out of the loop. If you need one of several triggers to break out of the loop then OR (||) would be needed. If you need several triggers to be set at the same time … | |
![]() | Re: How are you retrieving the data from the database? |
Re: You're using post increment instead of pre increment. Which means the value of o changes after you assign c to it. Using pre increment o will increment then c will be assigned to it: *++o = c; | |
Re: Drop the second index. Because the value is NULL, which is the string terminator, basically you're asking to read the first character of a NULL string, which doesn't exist. printf("strings_line_tokens[]: %c %d \n",(char)strings_line_tokens[1], (int)strings_line_tokens[1]); As for detecting the NULL you can use 0 like you've done or you can make … | |
![]() | Re: One thing to look at, is date supposed to have an extra e on the like you have? ![]() |
Re: Not sure if I understand you right, but, something like a While loop might work | |
Re: The C Standard Library(stdlib.h) includes [qsort](http://www.cplusplus.com/reference/cstdlib/qsort/) which can be used to sort an array. That library also includes a binary search function([bsearch](http://www.cplusplus.com/reference/cstdlib/bsearch/)). | |
Re: Another way would be to use Dynamic Memory Management([calloc](http://www.cplusplus.com/reference/cstdlib/calloc/), [malloc](http://www.cplusplus.com/reference/cstdlib/malloc/), [realloc](http://www.cplusplus.com/reference/cstdlib/realloc/), [free](http://www.cplusplus.com/reference/cstdlib/free/)) | |
Re: Here's one way using LINQ: Private Sub buttonSave_Click(sender As Object, e As EventArgs) Dim filePath As String = Me.TextBox1.Text Dim delimiter As String = ";" Dim sb As New StringBuilder() 'create columnNames: sb.AppendLine(Join((From c As DataGridViewColumn In DataGridView1.Columns Where c.Visible = True Select c.HeaderText).ToArray, delimiter)) 'get values from visible columns … | |
Re: To get arbitrary positioning, you'll probably need something like a vector, which is basically a dynamic array. What are your requirements? Perhaps you'll be able to get better ideas. | |
Re: Not sure if you have a problem or if this is supposed to be a snippet. However, one thing I noticed, you are accepting user input without verifying its validity. Using the TryParse method instead of the Parse method would help in this. Something like this: do { Console.Write("Ener Regular … | |
Re: One thing I see, is that you're passing the `moved` array to the print function incorrectly: print(n,moved); Without any sort of error message, it's hard to say if that is the problem though. | |
Re: Biggest problem I can see, is that you are trying to pass a binary function to the for_each function that is expecting a unary function. That's besides the syntax error(semi-colons instead of commas), typing error(2 p's in employee) and missing reference(#include <algorithm>). Also when using an object like that you … | |
Re: If you're writing for only windows, one way would be to use the .net libraries. With the latest version of Visual Studio you get fairly good realtime syntax handling and Intellisense as well as being able to create a C++ project that will interact directly with the .net librairies, that … |
The End.