|
Here [^]is the solution
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I have been asked to build a command prompt based application that will bypass the printer driver and connect directly to the printer to print? Does anyone have any suggestions on how to do this. And How to build a printers INIT string?
|
|
|
|
|
Why have you been asked to do something that you plainly don't know how to do ? What resources were you given to do this ? Or did you start on the job today and were given a task and the URL to code project, so we'd do it for you ?
I imagine this is a pretty complex task, and I'd have thought C++ would be better suited to it, than C#.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I need the ability to read in data from an Excel file, operate on it, and then create a new excel file.
Currently I have the code I need to use the Interop library to manualy open excel and read the data from there. However, this seems to be very unstable as any prompt for user input results in the program being halted.
My other plan would be to convert the .xls into .csv and then into .xml and read that data in, however I have never dealt directly with .xml files before. My biggest problem with reading in the data is that there are many blank cells within the excel file, the ability to read data from the cells directly using the cell address (such as B4 or 5,8) is a main priority of my solution.
Also, converting .xls => .csv => .xml to produce a .xml and then convert .xml => .csv => .xls seems like a lot of unnessasary work.
Is anyone able to point me in the right direction as to what would be the easiest way to do this? I am fairly new to programming, but am competent enough to understand well documented code that tries not to be too obscure.
|
|
|
|
|
You shouldn't need to convert to csv/xml. You could open your xls as an ODBC datasource. Here is an article on CP on how to so that:
Reading Excel files using ODBC[^]
|
|
|
|
|
this.size.height = 100
frm.activeform.size.height = 100
does not work.
what is wrong plz
|
|
|
|
|
Try it this way:
this.Size = new Size(Width, 100);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
the height and width values of the size property can not be modified, you can either do as dave suggested and assign a new instance of size. Or use the Width and Height properties of the form, which can be set. as follows...
this.Width = 100;
this.Height = 200;
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
I have created a website in C#, Asp.Net on .Net framework 2.0, I want to track (number of hits) for referral URL(as www.mysite/goto/dom) which redirect me to actual URL(www.mysite/abc/default.aspx?client=dom) I am able to track actual URL by Google Analytic code but having no control on referral URL(but I want to track them, Please help me regarding this issue or forward me any article) Thanks.
|
|
|
|
|
|
Hi there
First excuse me for my bad english text
I am new in c# and i have a phonebook project.I want to control input name.
For example just [a-z] and space can type in textbox.
i think regular expression is good class for this but i dont know how do it.
can anyone help me? pleas give me a complite answer.
Thank u very very much for your help
|
|
|
|
|
I would implement that in the KeyPress event handler instead.
|
|
|
|
|
Thanks for your response
|
|
|
|
|
the following code should work and will return a bool for you...
System.Text.RegularExpressions.Regex.IsMatch(textbox1.Text, "^[A-Za-z ]*$");
Life goes very fast. Tomorrow, today is already yesterday.
modified on Wednesday, September 2, 2009 11:17 AM
|
|
|
|
|
Dear musefan
Thank u for your help. That help me
|
|
|
|
|
Okay. So my first attempt in sorting the strings using Radix Sort is a failure(The one with converting all strings into ASCII code).
Now, what i want to do is use the strings directly to sort them out using Radix Sort. Is there any available source code that can sort strings using Radix Sort? I already got one source code but I think it's implemented in Java. I don't have any time to make my own code since it will be passed on saturday(GMT +8:00).
One question though. What programming language that uses CharAt() method? Is that Java? If so, what is the equivalent method of that in C#?
|
|
|
|
|
gamer1127 wrote: What programming language that uses CharAt() method?
It could be an Extension Method.
gamer1127 wrote: what is the equivalent method of that in C#?
Just use an index: c = s [ i ]
|
|
|
|
|
gamer1127 wrote: CharAt() method? Is that Java?
Yes.
In C#, you can index a string as if it were an array. The elements are of type char , and of course read-only.
|
|
|
|
|
This is the source code that I got. It's a msd Radix sort:
public static void msd(String[] a)
{
msd(a, 0, a.Length, 0);
}
private static void msd(String[] a, int l, int r, int d)
{
int N = a.Length;
if (r <== l + 1) return;
int[] count = new int[256];
for (int i = 0; i < N; i++)
count[a[i].charAt(d) + 1]++;
for (int k = 1; k < 256; k++)
count[k] += count[k-1];
for (int i = 0; i < N; i++)
temp[count[a[i].charAt(d)]++] = a[i];
for (int i = 0; i < N; i++)
a[i] = temp[i];
for (int i = 1; i < 255; i++)
msd(a, l + count[i], l + count[i+1], d+1);
}
How will I revise this so I can use it in c#?
|
|
|
|
|
count[a[i].charAt(d) + 1] -> count[a[i][d] + 1]
|
|
|
|
|
I'm still having a problem with my string sorting. I always get the IndexOutOfRange exception during runtime.
How will I solve that?
public static void SortByLastName(ref string[] arrayOfLastNames, ref string[] arrayOfFirstNames, ref string[] arrayOfPlateNum, ref string[] arrayOfType, ref string[] arrayOfYear)
{
Console.Clear();
int vehicleCountInt = 0;
Console.WriteLine("SHOW DATABASE: SORTING BY LAST NAME\n");
using (StreamReader countVehicle = new StreamReader("vehiclecount.txt"))
{
vehicleCountInt = Int32.Parse(countVehicle.ReadLine());
}
using (StreamReader outputLastNames = new StreamReader("lastnames.txt"))
{
int[] b = new int[vehicleCountInt + 1]; ;
for (int i = 0; i < vehicleCountInt; i++)
{
arrayOfLastNames[i] = outputLastNames.ReadLine();
Console.WriteLine();
}
}
int N = arrayOfLastNames.Length;
int W = arrayOfLastNames[0].Length;
string[] temp = new string[vehicleCountInt];
for (int d = W - 1; d >= 0; d--)
{
int[] count = new int[vehicleCountInt];
for (int i = 0; i < N; i++)
{
count[arrayOfLastNames[i][d] + 1]++;
}
for (int k = 1; k < 256; k++)
{
count[k] += count[k - 1];
}
for (int i = 0; i < N; i++)
{
temp[count[arrayOfLastNames[i][d]]++] = arrayOfLastNames[i];
}
for (int i = 0; i < N; i++)
{
arrayOfLastNames[i] = temp[i];
Console.WriteLine("{0}", arrayOfLastNames[i]);
}
}
}
|
|
|
|
|
You don't need ref for those arrays, you're not assigning to them
But wait, how can you be sure that those arrays are long enough?
tip: always tell where you get the exception.
I suspect it happens here: arrayOfLastNames[i] = outputLastNames.ReadLine();
Since there is no guarantee that arrayOfLastNames is long enough (its length is unknown)
|
|
|
|
|
Ok..Is there a way on how to solve that problem? I'm thinking of declaring an array that is large enough for me to store those names.
|
|
|
|
|
I hope you aren't asking for a way to declare an array of a given size..
int[] b = new int[vehicleCountInt + 1]; is one such declaration, but probably 1 too big (why are you adding one?)
If you are asking how to assign to an array which is a function parameter, well, ref is used for exactly that purpose, but out may be sufficient. But this "problem" is as trivial as the first.
|
|
|
|
|
Well I'm referring to how will I solve the problem about the uncertainty of the array's size. I've declared 5 text files with 30 data inside. Now what my groupmate did was create a text file and put there the total number of data inside the text files, and that's the vehicleCount .
Now what I'm thinking is declare an array that has a definite size (say 50) which will hold the data inside the text file(the 30 predefined data and the user's additional inputs). Will this solve the problem about the IndexOutOfRange exception?
|
|
|
|