376 Posted Topics

Member Avatar for PierlucSS
Member Avatar for bornwith

In your first listing, the variables you defined are local to the Main method and work as they should, as you have seen. In the second example, the variables are instance members of the class. Main, however, is a static method, which means it simply applies to calctest, not individual …

Member Avatar for apegram
0
127
Member Avatar for clutchkiller

Average Joe cannot download XNA, copy/paste from tutorials, and make a "Triple A" game. Average Joe can download XNA, fool around with it, and go back to playing Call of Duty after he realizes he can't program for squat. Motivated Novice can download XNA, put together the worst code imaginable, …

Member Avatar for jwenting
-3
141
Member Avatar for PRINCE01

[CODE] using System; class Program { static void Main(string[] args) { Foo foo = new Foo(); foo.Blah = 17; Foo foo2 = new Foo(); foo2.Blah = 36; foo.CompareTo(foo2); // uses IComparable<Foo> implementation ((IComparable)foo).CompareTo(foo2); // uses IComparable implementation } } public class Foo : IComparable<Foo>, IComparable { public int Blah { …

Member Avatar for apegram
0
123
Member Avatar for Ancient Dragon
Member Avatar for apegram

I work for a small company that develops websites for other companies, most of them local, some with a more regional or semi-national presence. I cannot tell you how many websites I've worked on where some guy has an idea and just barely enough cash to pay someone to develop …

Member Avatar for geekgoddess
1
242
Member Avatar for apegram

[CODE] int[][] jaggedArray = (from line in File.ReadAllLines(fileName).Skip(1) select (from item in line.Split('\t').Skip(1) select int.Parse(item)).ToArray()).ToArray(); [/CODE] This is a crazy example. It was sparked by what is probably a homework thread on another forum here, but it is basically reading in a tab-delimitted text file, stripping out the first row …

Member Avatar for ddanbe
3
700
Member Avatar for trippinz

You've asked this question before. You said you figured it out before. What has changed? As I said one of the other times, I gave you sample code for working with a generic list of Button objects. List<T>, where T can be any type you can come up with. ints, …

Member Avatar for Geekitygeek
-1
93
Member Avatar for ROTC89

Show the code for how you're consuming the class. A couple of items, though. 1) The program looks more like a Java program. Are you of a Java background (or perhaps is your teacher)? In C#, we use Pascal-casing to name methods. Basically, the first letter of each word is …

Member Avatar for apegram
0
141
Member Avatar for drichird

[CODE] static void Main(string[] args) { int[] array = new int[] { 1, 2, 3 }; DoSomething(ref array); foreach (int value in array) Console.WriteLine(value); Console.Read(); } static void DoSomething(ref int[] array) { array = new int[] { 2, 4, 6, 8, 10 }; } [/CODE]

Member Avatar for apegram
0
1K
Member Avatar for automata

It's not all that difficult, and is much easier if you have a firm grip on LINQ and extension methods. But first, [I]what have you tried? [/I] To start, I would suggest reading the contents of the fille using the File.ReadAllLines(fileName) method (System.IO namespace). That will read the contents of …

Member Avatar for ohsosexy
0
100
Member Avatar for cwarn23

Actually, I'm quite pleased with my current laptop, although I wish Windows 7 loaded faster. On the other hand, I don't play games on my computer, I stick to consoles.

Member Avatar for Biker920
0
139
Member Avatar for sandhya1212

More than likely it is a matter of the process not having write access to the folder where your Access database is located. Check user/folder permissions on the server.

Member Avatar for apegram
0
97
Member Avatar for abarlowa

The immediately visible error is the use of an unassigned local variable (input). Once that is fixed, you have the critical error of your code simply not working.

Member Avatar for jonsca
0
82
Member Avatar for trippinz

I provided an example working with a generic list of buttons, the "Button" being a common winform control. If you're using something other than the regular button, obviously List<Button> will not work. Make it List<[I]WhateverTheTypeYouNeed[/I]> instead. Search google and read up on generic collections in .NET and C#. But the …

Member Avatar for trippinz
-1
147
Member Avatar for GAME

Is this the same user as trippinz? Anyway, in the hypothetical scenario that you have all the textboxes stored in a List<TextBox> structure, you could do something like this. [CODE] // using statement: using System.Collections.Generic; List<TextBox> boxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5 }; // etc. // …

Member Avatar for GAME
0
182
Member Avatar for danturn

Show us what you've tried! Did the example I provided [URL="http://www.daniweb.com/forums/thread266791.html"]here [/URL]give you a good start? And is this homework, work-related, etc.?

Member Avatar for danturn
1
176
Member Avatar for GAME

To expand on what Narue has provided, here's a way to capture the information and format it and then clear the textboxes. Uses Linq, extension methods, etc. [CODE] var controls = this.Controls.Cast<Control>(); string[] texts = (from control in controls where control is TextBox select control.Text).ToArray(); StringBuilder builder = new StringBuilder(); …

Member Avatar for apegram
0
163
Member Avatar for clutchkiller
Member Avatar for cwarn23
1
130
Member Avatar for trippinz

Here's a slimmed down example of what I think you're looking for. I've created a form, 5 textboxes, 5 buttons. For the purposes of this example, the 5 values of note are A, B, C, D, and E. [CODE] using System; using System.Collections.Generic; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial …

Member Avatar for trippinz
0
231
Member Avatar for Mitja Bonca

Functionally, a simple text file is far different than a Word document. But as for creating a simple file, here is another method. [CODE] string[] temp = new string[] { "Apple", "Banana", "Cherry" }; string fileName = @"C:\Temp\junk.txt"; File.WriteAllLines(fileName, temp); [/CODE] Which would create a text file that looks like …

Member Avatar for apegram
0
113
Member Avatar for sallyroberts

XmlValidatingReader looks like it was phased out in the transition from .NET 1.1 to 2.0. Look at using XmlReader.Create() along with an XmlReaderSettings object instead.

Member Avatar for apegram
0
85
Member Avatar for danieldot

@ddanbe It hurts to have to correct you! But Juha's code does return 10 for i. The overload he used will return the portion of the string from starting index specified (1) all the way until the end of the string.

Member Avatar for danieldot
0
157
Member Avatar for Jasicamikayani
Member Avatar for muthu1802

Consider this modification of your code. [CODE] public string[] SelectTable(String pSqlstmt) { string str = null; // you declared this variable before but did not use it if (pSqlstmt.Contains("from")) { int strlen = pSqlstmt.Length; int strindfrom = pSqlstmt.IndexOf("from"); if (pSqlstmt.Contains("where")) { int strindwhere = pSqlstmt.IndexOf("where"); str = pSqlstmt.Substring(strindfrom, strindwhere); } …

Member Avatar for apegram
0
187
Member Avatar for sjn21682

You're comparing various parts of each line to each other (it appears), but if you want to see if the entire lines are equal, why not just compare the entire lines? A quick way to achieve this would be to use a static method of the type File to read …

Member Avatar for Geekitygeek
0
150
Member Avatar for PhiberOptik

What he means is that you established an array, but each element of the array is still null. You need to create instances of Point at each element before you can access any members.

Member Avatar for ~s.o.s~
0
101
Member Avatar for word.smith

I would step through the code and make sure it is doing what you think it should be doing. I can run your code on a smaller file, and a StringBuilder should be able to handle the number of "words" you're trying to throw at it, it can hold over …

Member Avatar for apegram
0
155
Member Avatar for danturn

I would suggest LINQ to XML. You can easily load the XML file into a IEnumerable<> of either a defined or anonymous type and then combine your elements however necessary for your output. Given the following file format: [CODE=XML] <?xml version="1.0" encoding="utf-8" ?> <rows> <row> <UDPName>10014535-Test</UDPName> <SpeedDialIndex>2</SpeedDialIndex> <Label>mobile</Label> <SpeedDialNumber>907********</SpeedDialNumber> </row> …

Member Avatar for apegram
0
258
Member Avatar for davidjennings

You've got a cartesian join. You're selecting multiple tables into your query without providing a joining statement to link the tables together based on 1 or more common fields. As a result, each row of each table is being combined with each row of the other tables so as to …

Member Avatar for davidjennings
0
126
Member Avatar for rockiesmagicnum

You did have an extra bracket, but you also had a class and functions dropped within your main method where you had copied/pasted the web code. Here is a fixed format you can continue to work on (not guaranteed to work as is, I only fixed your formatting issues). [CODE] …

Member Avatar for rockiesmagicnum
0
62
Member Avatar for nsxdude

It looks like you are filling a datatable within the dataset that already exists. You're reusing the same datatable, is that correct? You need to either clear the existing data from that datatable or remove the datatable from the dataset altogether before you call the Fill operation again. [CODE] ds.Tables.Remove("yourDataTableNameHere") …

Member Avatar for nsxdude
0
153
Member Avatar for sunilChoudhary

[CODE] Dim myDate As DateTime = DateTime.Now Dim dateFormat As String = "d-MMM-yy h:mm tt" Console.WriteLine(myDate.ToString(dateFormat).ToLower()) [/CODE] Output: 11-mar-10 10:13 am

Member Avatar for apegram
-1
96
Member Avatar for freshfitz

To strip everything following the first instance of '<script', you could use something like this. [CODE] update temptable set tempfield = LEFT(tempfield, charindex('<script', tempfield, 0) - 1) where tempfield like '%<script%' [/CODE]

Member Avatar for freshfitz
0
100
Member Avatar for deerowbear

You should be getting an ArgumentOutOfRangeException on this. [CODE] for (int i = 0; i < infixExp.Length; i++) { str = infixExp.Substring(i, i + 1); [/CODE] Your substring length (i + 1) is getting progressively longer with each iteration, and it won't be too many iterations before the length exceeds …

Member Avatar for deerowbear
0
259
Member Avatar for youdester

@youdester This thread is over 3 years old! If you have some code you'd like to share, you can start a new thread. Just be sure to use code tags to wrap your code. (See the (code) button). On that note, consider this example to streamline what you are doing. …

Member Avatar for apegram
0
150
Member Avatar for abrogard

If your website is on Windows hosting, chances are you have the ability to utilize ASP.NET, which would allow you to write web pages/applications in C#/VB running on top of the .NET framework. You'd have to check with your service provider.

Member Avatar for Mike Gale
0
195
Member Avatar for laptop545
Member Avatar for Renukavani
0
70
Member Avatar for Smith5646

When you do a for each and remove controls from the collection you're iterating over, it creates problems like the one you're having. Say if you have a list like item1 item2 item3 You do a for each loop over the collection and remove the first record and then move …

Member Avatar for L0u3
0
360
Member Avatar for all star

Can you post the code that is calling that particular function? My hunch is that your datetime argument is invalid.

Member Avatar for all star
0
82
Member Avatar for kerek2

[QUOTE=kerek2;1150499]Hi, i need your help to get date of birth (DOB) from the Age that given...example AGE = 45...so how to get the DOB?...tq[/QUOTE] You're not going to get a precise date of birth if all you have is the integer age. You may be able to get reasonably close …

Member Avatar for apegram
0
108
Member Avatar for Wraithmanilian

Canada's got other things going for it, too. For example, they're closer to Santa.

Member Avatar for vegaseat
0
143
Member Avatar for shanboy

What have you tried? Each different control is going to have different events available, and I won't even try to go through the list of them. For any given control you want to test, there's nothing better than simply going to google, typing in the control name, and usually that …

Member Avatar for apegram
0
133
Member Avatar for london-G

I would consider an XML format. [CODE] <?xml version="1.0" encoding="utf-8"?> <Quiz> <Question> <QuestionText>What date was time travel invented?</QuestionText> <Answer>July 4, 1776</Answer> <Answer>December 7, 1941</Answer> <Answer>August 16, 1977</Answer> <Answer Correct="true">November 5, 1955</Answer> </Question> <Question> <QuestionText>How much power is required for the flux capacitor to work?</QuestionText> <Answer>4 Palpatines</Answer> <Answer>3 Vaders</Answer> <Answer Correct="true">1.21 …

Member Avatar for london-G
0
154
Member Avatar for tchiky
Member Avatar for shubhamshah

Have you tried using a Random object? Perhaps consider generating a random number between 0 and the number of items in the ListBox control. With that number, you can select an item and use that to populate the TextBox.

Member Avatar for kvprajapati
0
267
Member Avatar for maria_mj

The error message indicates that you are using a RadioButtonList control instead of a standard RadioButton. To access the item that is selected in the control, you can utilize the .SelectedItem property (be careful, it can be null if the user has not made a selection) or to simply get …

Member Avatar for apegram
0
4K
Member Avatar for happygeek

If I can even think back that far (it has been so long), but I [I]believe [/I]it was a post on a C# prime number algorithm. Good times. I was such a different person then, I barely recognize myself.

Member Avatar for Dave Sinkula
0
525
Member Avatar for princekool

I don't believe there's a simple single-query method of constructing your list. You can accomplish it using a programming language of your choice, or you can use a procedure in SQL Server to produce your output. The below is not going to translate exactly for you, but it should give …

Member Avatar for apegram
0
253
Member Avatar for Gl0mby

You haven't defined the LargeCoins(), MediumCoins(), and SmallCoins() methods. Calling them within the loop and within the if blocks will work. One issue you presently have is that there is nothing within the loop to eventually bring about an exit condition. As such, and once you define the aforementioned methods, …

Member Avatar for Geekitygeek
2
125

The End.