376 Posted Topics

Member Avatar for toko

I'd revisit that assumption, there could be something else incorrect in your code. Consider this example. [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { int buttonID = 0; for (int i = 0; i < 10; i++) { …

Member Avatar for jmosquera1987
0
1K
Member Avatar for firstimer

You can persist values in a cookie, in session, or in viewstate. Here is a demo showing how to do this by using viewstate. [B]viewstatedemo.aspx[/B] [CODE] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="viewstatedemo.aspx.cs" Inherits="viewstatedemo" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" …

Member Avatar for firstimer
0
136
Member Avatar for sarsekim

Look into arrays and generic lists. And to correct your wording, you do not have two classes of the same type. The [I]type[/I] is the [I]class[/I]. You have two [I]objects[/I] of the same type. The class is the definition, the object is the intantiation.

Member Avatar for kvprajapati
0
112
Member Avatar for DaveTran

Two things [CODE] if (x <= 22.5f) { } if (x >= 22.5f && x <= 67.5f) { } [/CODE] In statements like these, if the value is exactly 22.5f, then you're allowing control to enter each of these if statement. One way of stating intent is if one statement …

Member Avatar for DaveTran
0
117
Member Avatar for elkinsdu

Try out LINQ to XML. Give this sample a spin. [CODE] using System; using System.Linq; using System.Xml.Linq; class Program { static void Main() { string xml = @"<OUTPUT version=""2.0""> <RESPONSE> <LOAN_DATA loan_id=""xxxx"" loan_number=""1111"" loan_type=""HE"" status_code=""OK""> <![CDATA[<MORTGAGE_LOAN xmlns=""http://www.something.com/CLF"" version=""1.0""> <APPLICANTS> <APPLICANT is_declined=""N"" first_name=""MARISOL"" last_name=""TESTCASE"" m_initial=""L"" middle_name=""L"" ssn=""000000001"" > </APPLICANT> </APPLICANTS> </MORTGAGE_LOAN>]]> …

Member Avatar for elkinsdu
0
229
Member Avatar for gloris

\ is used to escape special characters in strings or chars. To use it normally, you either need to escape it (making it \\) or you can use the @ character in front of the entire string. [CODE] string oneWay = "C:\\Temp\\somefile.txt"; string anotherWay = @"C:\Temp\somefile.txt"; [/CODE] So for your …

Member Avatar for gloris
0
89
Member Avatar for hitro456

You can write a generic function to return whatever type is required of a function. Here is a simple example. [CODE] public T GetDefaultValue<T>(T input) { return default(T); } [/CODE] And using it [CODE] DateTime myDate = GetDefaultValue<DateTime>(); int myInt = GetDefaultValue<int>(); double myDouble = GetDefaultValue<double>(); string myString = GetDefaultValue<string>(); …

Member Avatar for apegram
0
113
Member Avatar for sarsekim

You do not cast strings to int in such a manner. Your options boil down to these: [CODE]Convert.ToInt32([type] input) int.Parse(string input) int.TryParse(string input, out int result)[/CODE] Of these, the first 2 will throw exceptions if you do not provide a valid input that can be converted to an integer. The …

Member Avatar for sarsekim
0
160
Member Avatar for danturn

That's some crazy multi-level grouping that you need to do, more than likely. And it's possible. Run the following sample based upon what you've already done: [CODE] string xml = @"<rows><row> <DNOrPattern>0444</DNOrPattern> <HuntList>HL-1104 C Capital</HuntList> <LineGroup>LG-1000-COREVM1</LineGroup> <RNAReversionTimeout>4</RNAReversionTimeout> <DistributionAlgorithm>Top Down</DistributionAlgorithm> <Member>20130</Member> </row> <row> <DNOrPattern>1015</DNOrPattern> <HuntList>HL-1104 B Ltd</HuntList> <LineGroup>LG-1000-COREVM1</LineGroup> <RNAReversionTimeout>4</RNAReversionTimeout> <DistributionAlgorithm>Top Down</DistributionAlgorithm> …

Member Avatar for danturn
0
147
Member Avatar for ROTC89

You're saying this [CODE] foreach (Person search in Page) [/CODE] Which suggests Page should be something equivalent to an IEnumerable of Person. (List<Person>, IEnumerable<Person>, etc.). However, in your Page declaration and instantiation, you have this [CODE] private List<string> Page; ... Page = new List<string>(); [/CODE] Hence the error. You have …

Member Avatar for apegram
0
101
Member Avatar for ari200429

You do, of course, realize that at 7 digits and allowing 3 possible characters per digit, you're going to generate 2187 different "words." If you allow for 4 characters for 7 (pqrs) and 9 (wxyz), then you can get 3888 words. Here's something I quickly put together, and I'm even …

Member Avatar for apegram
0
578
Member Avatar for NOLK

You could try something simple like [CODE] int mathOperator = random.Next(1, 5); // gives value of 1-4 switch (mathOperator) { case 1: result = leftSide + rightSize; break; case 2: result = leftSide - rightSize; break; case 3: result = leftSide * rightSide; break; case 4: result = leftSide / …

Member Avatar for NOLK
0
1K
Member Avatar for klarson95

Start by opening your copy of Visual Studio or Visual Basic Express. Click on "Create Project" and choose "Console Application." Give it a descriptive name. Once you've gotten this far, type some code, then come back and post it if you've got more questions.

Member Avatar for G_Waddell
0
77
Member Avatar for DaveTran

Go with whatever seems readable to you. [CODE]return a == b && x == y; [/CODE] Is fine with me. Others might want to see something more like [CODE] if (a == b && x == y) return true; return false; [/CODE] Understand that the logical operation I wrote is …

Member Avatar for DaveTran
0
93
Member Avatar for Bigfoot73

You will not need to specify virtual in B to override it in C. The virtual of A will cascade, essentially. Run the following sample: [CODE] using System; class Program { static void Main() { C c = new C(); c.Y(); Console.Read(); } } class A { public void X() …

Member Avatar for Bigfoot73
0
125
Member Avatar for jk451

[QUOTE=jk451;1174835]Running it with the VS 2008 C# compiler, the exception that's thrown in the code actually never gets propagated...[/QUOTE] Your code is doing exactly what you have told it to do. During the creation of the ArgumentNullException, you created a DivideByZeroException. 1) The creation of the ArgumentNullException did not succeed …

Member Avatar for jk451
0
178
Member Avatar for jt3204

That looks like the code from an IL disassembler such as ILDADM (comes with Visual Studio), it would be in the program's manifest. What you're looking at are using statements. It translates to [CODE] using System; using System.Windows.Forms; using System.Drawing; [/CODE] If you'd like, you can do a google search …

Member Avatar for jt3204
0
229
Member Avatar for Lolalola

You need to be in the main thread to set the text. Try something like this modification of your code. [CODE] private void Form1_Load(object sender, EventArgs e) { Thread demo = new Thread(new ThreadStart(this.ThreadProc)); demo.Start(); SetText("Main thread"); } private void ThreadProc() { while (true) { Thread.Sleep(1000); SetText(DateTime.Now.ToString()); } } private …

Member Avatar for Lolalola
0
91
Member Avatar for bluem1

Use the TextChanged event. [CODE] Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged If (TextBox1.Text.StartsWith(TextBox2.Text)) Then TextBox2.BackColor = Color.LightGreen Else TextBox2.BackColor = Color.Salmon End If End Sub [/CODE]

Member Avatar for bluem1
0
117
Member Avatar for sachintha81

Use a Regex. [CODE] using System; using System.Text.RegularExpressions; class Program { static void Main() { string input = @"<JDF ID=""n20090409EQ0001"" Type=""Product"" JobID=""000004-01"" xmlns=""http://www.CIP4.org/JDFSchema_1_1"" Status=""Waiting"" Version=""1.3"" xsi:type=""Product"" JobPartID=""B30"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:scr=""htt://new.scr.url/abc"" Activation=""Active""......."; string pattern = "xmlns:.*?\".*?\""; MatchCollection matches = Regex.Matches(input, pattern); foreach (Match match in matches) Console.WriteLine(match.Value); Console.Read(); } } [/CODE] It …

Member Avatar for fesmaeili
1
167
Member Avatar for Lolalola

Modify your Students declaration to match the following: [CODE] Students info = new Students(); [/CODE]

Member Avatar for Lolalola
0
66
Member Avatar for PierlucSS

The first part of the query is retrieving the files in the given directory. The second part is a select projection that takes a given filename, loads an XDocument and retrieves all descendants of that document of a particular name. In terms of the delegate signature for the inner function, …

Member Avatar for PierlucSS
0
145
Member Avatar for fiaolle

You were not providing the proper method signature when you were attempting to override OnPreRender. The proper signature is the following [CODE=VB.NET]Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)[/CODE] Overriding with the invalid signature didn't work because there was nothing to override with that signature. Omitting "overrides" and accepting a different …

Member Avatar for kvprajapati
0
182
Member Avatar for max1million

1) A short is not an 8-bit integer. short is Int16. 2) There could be a better method than this, but here's something you can do. [CODE] byte b = 208; char[] chars = Convert.ToString(b, 2).ToCharArray(); Array.Reverse(chars); b = Convert.ToByte(new string(chars), 2); Console.WriteLine(b); Console.Read(); [/CODE]

Member Avatar for ddanbe
0
221
Member Avatar for The Dude
Member Avatar for checho

You can do this with a pair of loops. Including whitespace, using statements, and console output, I've coded a full program to work with a fixed array of integers in 28 lines. I'll give you the general description of the looping structure, sort of like pseudocode, and you should see …

Member Avatar for checho
1
741
Member Avatar for DaveTran

Strings are immutable. When you have set a string equal to a value, that value does not change in and of itself. Rather, changes are returned in a [I]new[/I] string object. To see your changes, you would write something like [CODE] string str = "a"; str = str.Remove(0); [/CODE]

Member Avatar for DaveTran
0
102
Member Avatar for trippinz

You have an if statement without surrounding brackets, which means the next line of code following the if statement is the single embedded statement of the if condition. You have commented out the line directly following the if statement. That makes the [I]next[/I] statement the single embedded statement of the …

Member Avatar for trippinz
0
291
Member Avatar for kiranbvsn

You can place a content placeholder in the header area of your master page. That way child pages can choose to utilize that placeholder for items such as scripts, extra stylesheet references, etc., that may not be applicable to all pages.

Member Avatar for amitshrivas
0
161
Member Avatar for ddanbe

I tried your algorithm and it works, however I found that you need to increase your number of executions for it to deliver a really good shuffle. 5 iterations leaves a lot of cards in the same order as the original. I bumped it up to 100 to get a …

Member Avatar for ddanbe
2
781
Member Avatar for andrew2325

Here's an idea. [CODE] using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { string fileName = @"C:\Temp\blah.txt"; var valueHolder = new { StringRow = File.ReadAllLines(fileName).First(), NumericRows = File.ReadAllLines(fileName).Skip(1).Select(line => int.Parse(line)).ToList() }; Console.WriteLine(valueHolder.StringRow); valueHolder.NumericRows.ForEach(number => Console.WriteLine(number.ToString())); Console.Read(); } } [/CODE] blah.txt [CODE=Text] Blah 27 5 1098 …

Member Avatar for Geekitygeek
0
167
Member Avatar for DaveTran

Always let j be >= i so it doesn't cover old ground. [CODE] int maxIndex = 5; for (int i = 0; i <= maxIndex; i++) { for (int j = i; j <= maxIndex; j++) { Console.WriteLine("i = {0} j = {1}", i, j); } } [/CODE]

Member Avatar for DaveTran
0
308
Member Avatar for fsn812

Personally, I'm not a fan of PHP, but I don't really have a dog in the fight because I don't use Java, either, as my place of employment does .NET. All other things behind held equal, my "unofficial official do not try this at home" litmus test is what's in …

Member Avatar for mama_rock
0
529
Member Avatar for makachuki

Look at some of the responses there. oops... wrong link before... how about this one [url]http://www.daniweb.com/forums/thread268827.html[/url]

Member Avatar for ddanbe
0
299
Member Avatar for noey699

1) list[list.Count-1] 2) Is x a public property or is it a method? More info on your implementation, please. 3) for (int i = 0; i < list.Count; i++) 4) I think you know by now.

Member Avatar for noey699
0
94
Member Avatar for mercury113
Member Avatar for domingo

[QUOTE=domingo;1162317]hi i tried casting the object but it doesn't seem to help. it casted the timespan asd but it gives me more errors, can anyone please help me?[/QUOTE] Cast the object from the reader. Something like [CODE] if ((TimeSpan)rdr[blah] < asd) { } [/CODE]

Member Avatar for kplcjl
0
197
Member Avatar for drspock

You can increase the size that you can upload by adding/modifying the httpRuntime element under system.web in web.config. Example: [CODE] <httpRuntime maxRequestLength="20000" executionTimeout="900" /> [/CODE] This will allow request streams of 20000 KB (to support large uploads) and bump the timeout of a page up to 900 seconds.

Member Avatar for vglass
0
198
Member Avatar for j_808

Sounds to me like your textbox "txtStorageChargeFee" is not populated. On that note, do not count on a user entering a valid numeric value in your application. Do not assume the user is smart, observant, or benevolent. Assume the user is a malevolent idiot driven by malice or ineptitude and …

Member Avatar for j_808
0
4K
Member Avatar for BrianWren

The database forums are subforums within the web development forum area. Here's a link to MS SQL. [url]http://www.daniweb.com/forums/forum127.html[/url] As for your issue, try this link. [url]http://support.microsoft.com/kb/918685[/url] Also, you may need to (re)install the .NET framework.

Member Avatar for apegram
0
109
Member Avatar for toko

You need to instantiate the array before you can use it. Consider this example: [CODE] int[] myArray; myArray[0] = 10; // error: Use of unassigned local variable 'myArray' [/CODE] It should be something like: [CODE] int[] myArray; myArray = new int[5]; // instantiate array myArray[0] = 10; [/CODE]

Member Avatar for toko
0
102
Member Avatar for jez23

Under no circumstances. [url]http://www.daniweb.com/forums/announcement58-2.html[/url]

Member Avatar for abhay1234
-3
315
Member Avatar for danturn

You need to call the .Add method instead of trying to set the List to the string. You have the .Add method in your property setter, but that's not going to be called with your given syntax.

Member Avatar for danturn
0
885
Member Avatar for jakewebb

You can use static methods of the class File to create a file and write text. You can also create an instance of the class StreamWriter to create and write to a file. Both are in the System.IO namespace. Here is a usage example of both. [CODE] Imports System.IO Module …

Member Avatar for jakewebb
0
1K
Member Avatar for ranuvishwakarma
Member Avatar for ranuvishwakarma
-1
59
Member Avatar for pepsy11

System.Data.ADO does not exist. The article you linked to was written in 2001 when .NET was still in beta. The final release and subsequent releases use objects in other namespaces. As adatapost said, you should use objects within a namespace that is specific to your database connection type. If you …

Member Avatar for pepsy11
0
89
Member Avatar for jlego

[CODE] Dim value As Integer = 6 Select Case value Case 1, 2, 3 MessageBox.Show("Blah") Case Else MessageBox.Show("Errr") End Select [/CODE]

Member Avatar for jlego
0
98
Member Avatar for vbnoob
Member Avatar for apegram
0
361
Member Avatar for JohnnyT

Theoretically, both could be valid. You could conceivably have a situation where you allow the modification of _field as long as _field is within a given range. Once it leaves that range, the field is essentially frozen. However, in the likely scenario, option 2 is more likely what you were …

Member Avatar for JohnnyT
0
132
Member Avatar for bunnyboy

That's actually pretty good. You can turn the XML document into a jagged array of floats, but to my knowledge the only way to turn it into a true 2D matrix is to iterate over the result of the query. Here's my alternate code. [CODE] using System; using System.Linq; using …

Member Avatar for bunnyboy
1
105

The End.