|
Use an overload of Int64.Parse to convert your string.
|
|
|
|
|
|
Hi Guys,
How to validate a TIME?
- After selecting the data from the database SQL SERVER I need to validate the time. IF it's > 12:00 am then I will not accept that particular record no specific dates.
ex0. 2004/06/20 12:01:43 AM - this is not allowed
ex1. 2004/06/20 12:00:01 AM - this is not allowed
if I used this sql statement using the ex0 or ex1 value it gives me a "0" value
select datepart(hh,requestdate) from dtrequest where requestno='DRAFT104' group by requestdate
Anybody who can direct me to a page where I can read and give me idea or solution, or if you can help me.
Thanks
/Dabuskol
|
|
|
|
|
dabuskol wrote:
IF it's > 12:00 am then I will not accept that particular record no specific dates
Then what records are you accepting? 12AM == Midnight, 12PM == Noon
So, the result you are getting from the datepart is correct. Zero-hundred-hours == Midnight.
When dealing with dates and times I always use the 24-hour clock - it is much easier to work with.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
|
dabuskol wrote:
12 PM..
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
hello there,
i want to take lively images from a webcam which connects to my PC from USB.
if you help me i will be very very happy.
have nice work.....
turgaytr@hotmail.com
T.A
|
|
|
|
|
you'd better have the driver and SDK of the webcam.
then you can do it better.
|
|
|
|
|
|
:-Ohai there,
i have a form with controlbox in my application. If the user click on close button. then I want to show a message box(MessageBoxbuttons.YesNocancel). i wrote different operation to handle all this three choices. but the funny thing is no matter if i click yes or No or Cancel this will dispose the form.
i want to dispose the form if the user select Yes.
Other wise i need to keep the form active( If user choose cancel or no).
any idea
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
sreejith ss nair wrote:
any idea
Yep, you need to override the OnClosing event and capture the DialogResult from your user. Based upon the users response, change the Cancel property of the CancelEventArgs and pass it to OnClosing of the base class. Here is a quick example:
protected override void OnClosing(CancelEventArgs e)
{
DialogResult r;
r = MessageBox.Show("Do you want to quit?", "Quiting",
MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if(r == DialogResult.No)
e.Cancel = true;
base.OnClosing (e);
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
nice shoot dear
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
I want to draw many strings in graphics, but I don't know how to get the size of the string in pixel (not the Length) to control them..
( As the function CSIZE GetTextExtent(CString) in Visual C++ )
Can you help me?
Cuoc doi ai biet dau ngay mai...
|
|
|
|
|
Minh Tong Tong wrote:
Can you help me?
Sure, if you read the MeasureString[^] method of the Graphics class, it returns a SizeF structure which gives you both the Height and Width of the string measured in pixels.
- Nick Parker My Blog | My Articles
|
|
|
|
|
does anyone have any straightforward method of clearing the console screen with an explanation?
i know it can be done...
|
|
|
|
|
|
thank you. i read it and implemented it. however, everytime i try to compile, it gives me an error
"needs an object reference for the nonstatic method 'nsClearConsole.ClearConsole.Clear()'"
so i created an object:
nsClearConsole.ClearConsole cls = new nsClearConsole.ClearConsole();
then i used it:
cls.Clear();
but when i compile, it says something about cls not being a namespace or class (did you miss a using or assembly reference?) or something like that...
any help?
|
|
|
|
|
Are you trying to write this as a singleton class? The following works for me:
using System;
using System.Runtime.InteropServices;
namespace Example
{
class ConsoleClass
{
private const int STD_OUTPUT_HANDLE = -11;
private const byte EMPTY = 32;
private int hConsoleHandle;
public ConsoleClass()
{
hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
}
[StructLayout(LayoutKind.Sequential)]
struct COORD
{
public short x;
public short y;
}
[StructLayout(LayoutKind.Sequential)]
struct SMALL_RECT
{
public short Left;
public short Top;
public short Right;
public short Bottom;
}
[StructLayout(LayoutKind.Sequential)]
struct CONSOLE_SCREEN_BUFFER_INFO
{
public COORD dwSize;
public COORD dwCursorPosition;
public int wAttributes;
public SMALL_RECT srWindow;
public COORD dwMaximumWindowSize;
}
[DllImport("kernel32.dll", EntryPoint="GetStdHandle", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", EntryPoint="FillConsoleOutputCharacter", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int FillConsoleOutputCharacter(int hConsoleOutput,
byte cCharacter, int nLength, COORD dwWriteCoord,
ref int lpNumberOfCharsWritten);
[DllImport("kernel32.dll", EntryPoint="GetConsoleScreenBufferInfo", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int GetConsoleScreenBufferInfo(int hConsoleOutput,
ref CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
[DllImport("kernel32.dll", EntryPoint="SetConsoleCursorPosition", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int SetConsoleCursorPosition(int hConsoleOutput, COORD dwCursorPosition);
public void Clear()
{
int hWrittenChars = 0;
CONSOLE_SCREEN_BUFFER_INFO strConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
COORD Home;
Home.x = Home.y = 0;
GetConsoleScreenBufferInfo(hConsoleHandle, ref strConsoleInfo);
FillConsoleOutputCharacter(hConsoleHandle, EMPTY,
strConsoleInfo.dwSize.x * strConsoleInfo.dwSize.y, Home, ref hWrittenChars);
SetConsoleCursorPosition(hConsoleHandle, Home);
}
}
class Demo
{
[STAThread]
static void Main(string[] args)
{
ConsoleClass ClearMyConsole = new ConsoleClass();
Console.WriteLine("THIS IS FIRST LINE");
Console.ReadLine();
ClearMyConsole.Clear();
Console.WriteLine("THE CONSOLE WAS CLEARED");
Console.WriteLine("Hit Enter to Terminate");
Console.ReadLine();
}
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
im using it as a .dll to another file.
using nsClearConsole;
and then i called it with a nsClearConsole.ClearConsole object called "cls".
cls.Clear();
am i doing something wrong?
|
|
|
|
|
You can compile it separately, that's not a problem. nsClearConsole should be the namespace (for your example), and as long as you have included a reference to that assembly and included the using nsClearConsole; within your code you should be fine. You don't need to prefix the ClearConsole class with nsClearConsole unless you are using another namespace somewhere that contains a ClearConsole class (unlikely).
- Nick Parker My Blog | My Articles
|
|
|
|
|
thank you for your patience. as it turns out, it was my own stupidity for the errors. my problem was i was calling the Clear() method in another method, not Main(), where i had created the cls object.
its late, im tired, stupid mistake, dont know why i didnt see it, i just created the object inside the new method.
thank you very much!
ip
and thanks for the namespace.class abbreviation... i must be dead tired... not thinking straight...
|
|
|
|
|
Hi,
I have the code below to draw an image:
Rectangle rect = new Rectangle(100,100,110,180);
g.DrawImage(this.pictureBox1.Image, rect);
I notice that the image will keep within the constraints I've set (110,180), but the image will distort. Is there a way to have the image reduce proportionately?
Thanks,
Ron
|
|
|
|
|
myNameIsRon wrote:
Is there a way to have the image reduce proportionately?
You can use the GetThumbnailImage method of the Image class. There is an example on MSDN here[^].
- Nick Parker My Blog | My Articles
|
|
|
|
|
please help me ,howa can I find Activeskin skins...
how can I download it.....?
Ahmed Gaser
|
|
|
|
|
Like everything else: google[^].
This forum is for questions about C# and using it in projects; not about specific projects (even if Activeskin is written in C#) or products.
Microsoft MVP, Visual C#
My Articles
|
|
|
|