|
Whats the betting he just puts <pre>...</pre>tags around the existing unformated code?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Richard MacCutchan wrote: Secondly if you do not understand the code then you really should not be trying to use it.
I don't think this is the right way to look at it. Just because you don't understand the code doesn't mean you shouldn't try to use it in order to gain said understanding.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I think the rest of my comment tried to put this in context. I was trying to make the point that getting someone else to modify the code to do what he wants will not enhance his understanding of it.
|
|
|
|
|
at first excuse me because of confusing you i corrected the code and here is the site that i downloaded the file:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1339&lngWId=10[^]
|
|
|
|
|
Richard MacCutchan wrote: if you do not understand the code then you really should not be trying to use it
That depends on what the code is! Most of us use code all the time that we don't understand - in the .net framework. And it truly would be a waste of time to study every implementation detail (most of which are undocumented!) of the primitive types before permitting oneself to use them. I do not know the exact representation of System.Decimal nor what bit-level manipulation it performs to carry out a multiplication, but it would be ridiculous to claim I shouldn't use decimals for that reason.
Also, even code that was not written with the intent of becoming a library (though most code should be written that way imo!) can still be of good quality and of great utility. Trying to use it is sometimes the most effective way to learn about it, whether it's good or bad code, especially if one does not have access to documentation.
|
|
|
|
|
This reply was aimed at the OP, who has downloaded some code from the internet that they admit to not understanding, and then wants a major change made to implement a feature that they probably understand less. It was not aimed at people who provide the answers on these forums. And I know that we all use unfamiliar code to learn new things, but we also spend a lot of time answering questions like this from people who have not taken the time to learn some of the basics.
|
|
|
|
|
OK. I think we've both made some valid points. It's not necessary to interpret any additional perspectives as implying "you're wrong" and it's not really a competition.
|
|
|
|
|
dojohansen wrote: It's not necessary to interpret any additional perspectives as implying "you're wrong"
I was not for a moment implying this, so I hope you did not read it that way. I do accept the points you made, I was merely trying to clarify my earlier message which may not have been as clear as I thought it was.
|
|
|
|
|
And by the way,
Richard MacCutchan wrote: but we also spend a lot of time answering questions like this from people who have not taken the time to learn some of the basics.
If we do, we do so only by choice. (Reading them is at least partly another matter.)
|
|
|
|
|
First, you have to tell us where you got the code so we have a context in which to help yopu.
Second, you need to properly format the code you posted into a properly tagged PRE block.
Third, you need to use punctuation in your description so we can read it.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
|
Thank you for putting the proper tags around your code. The first thing that jumps out is that you're using int types for your interop methods. You should be using IntPtr so that the code will run reliably on both 32-bit and 64-bit operating systems.
Beyond that, I think you're going to have to find some additional code (or technique) that allows you to select a connected video capture device. I believe this will involve familiarity with the DirectX SDK, and more specifically buding what they call "graphs" to connect the various devices.
You may be able to use WMI to detect devices connected to the system (especially if they're USB or Firewire devices, but I've never done this before, so yo're gonna have to do the research.
Ain't programming fun?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
thank u for your post
where should i exactly change int to intptr and what is the difference
thanks
|
|
|
|
|
I believe it's the external methods that return int and that they should return IntPtr. These are windows api functions and though I didn't look at them individually they probably return windows handles. Such handles will be 32-bit on 32-bit systems but 64 bits on 64-bits systems. In other words they have nothing to do with your problem, but since int is just shorthand for Int32 you should use IntPtr instead, and your code would (or at least could) then work on 32-bit and 64-bit platforms. Also, if any of the parameters to these methods are handles they too should be IntPtr, but you'll likely find out simply by changing the return type of the extern methods and building, since any handles passed to one of these will come from one of these...
|
|
|
|
|
I have to develop an application that will capture the packets and display it information using winpcap..and for that i need help.how can i use winpcap in c#?? plz help me as I m already out of time
|
|
|
|
|
I have a data grid viewer populated from a SQL Server stored procedure which returns any number of columns from a minimum of 4 to a maximum of unknown columns.
I need to have the ability to print the entire grid.
This I can do.
However, to print the grid to specifications
-- I need to be able to print it on pages the size of 42x36 and 72x72.
-- I need to be able to visually scale the entire grid to one page?
Please help. what needs done for this ability?
|
|
|
|
|
Hello. I'm trying to get something like when a user inputs B, he gets back ß. I'm using
string b = "ß";
string what1 = Console.ReadLine();
if (what1 == "b")
{
Console.Write(b);
}
and it doesnt seem to work. Any Help?
modified on Friday, November 20, 2009 8:43 PM
|
|
|
|
|
What do you mean by "it does not work"? You need to be more specific in order for us to try to help you.
The fact that you're writing to the console leads me to believe you're seeing a block character instead of β. That's probably because the console font being used is incapable of rendering anything other than a limited character set.
/ravi
|
|
|
|
|
Nope, it can print the "ß" (Double S sound in German)
But what I want is, when someone Enters the character "b" it prints "ß"
But its just not printing anything when I type b.
|
|
|
|
|
Console.ReadLine() returns only after a newline character is entered.
/ravi
|
|
|
|
|
Hi,
From the MSDN documentation: "Console.ReadLine() reads the next line of characters from the standard input stream." That means it waits until you enter whatever you like, and terminate it by hitting enter.
It you want your program to react on a single key being hit, you might consider using Console.ReadKey().
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Then how would I implement it so if b was pressed the ß comes out?
would i represent the string what with Console.ReadKey();? Or would I completely rework the code?
|
|
|
|
|
aaffbbww wrote: Then how would I implement it... ?
Start by reading the documentation on the classes/methods you are considering. Get used to help yourself, locate MSDN and/or use Google and learn how to search things. By now you have typed ten times more characters in this thread than it takes to code what you want.
aaffbbww wrote: would I completely rework the code?
Yes you may have to rework several of all 6 lines of code you have shown.
FWIW: it probably would be a good investment to spend some money and time in buying and studying an introductory book on C#.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
If you're confused I suggest you run in debug, with a breakpoint at the 'if'.
When it reaches that point (see below comments for some reasons why it may not) you can check and see what the value of 'what1' is. If it is not "b" then that explains why it is not working and you can figure out what to do from there.
If you're asking a more general question (like is this the best way to achieve what I'm trying to achieve) then you need to let us know what you're trying to achieve. It's unlikely (in my experience) that your entire logic is simply to replace every lower case b with a Beta character.
If, for example, you want to also replace any 'T' with a 7, E with a 3 (or whatever) then having a whole bunch of Ifs is probably not the best way to go about it.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
This will give you a starting point. But handling key-by-key input isn't totally straightforward to do properly. Users will expect normal console functionality to work, including arrow keys, backspace, selecting some text using the mouse and then typing or hitting backspace, cutting and pasting and so on.
This uses ReadKey and intercepts the console, meaning the character is not written. However, other side effects such as changing the cursor position still apply, so if the user presses backspace for example the cursor moves but the character is not removed.
I can't be bothered to try and work out all the specifics for you, but maybe you'd be better off not intercepting and instead writing a backspace and then the double-S char after a 'b' has been input.
class Program
{
static void Main(string[] args)
{
Console.WriteLine(
"This strange program won't let you type the letter 'b', systematically replacing it with 'ß' instead, "
+ "even though German has the letter 'b' also. Type away, and type 'exit' to quit. Do it now; this "
+ "really is pretty useless.\r\n\r\n");
string s;
while ((s = prompt("Input>")).ToLower() != "exit")
{
Console.WriteLine("Fantastic, you wrote: {0}\r\n", s);
Console.WriteLine();
}
}
static string prompt(string lead, params object[] args)
{
if (args.Length > 0)
lead = string.Format(lead, args);
Console.Write(lead);
var input = new StringBuilder();
while (true)
{
var key = Console.ReadKey();
char c = key.KeyChar.ToString().ToLower()[0];
if (c == '\r')
break;
switch (c)
{
case 'b':
c = 'ß';
break;
default:
c = key.KeyChar;
break;
}
input.Append(c);
Console.Write(c);
}
Console.WriteLine();
return input.ToString();
}
}
|
|
|
|