|
Hi Guys,
In C# Is there any way to find a date (paterns: 01/11/2005, 1/2/06, etc) in a string or text file?
eg:
string transcation = "Transaction initiated on 3/5/2005 and approved on 12/09/2006";
Now i need to extract the dates from this string, no prior knowledge of what the string contains & the date format could be different.
Thanks
Mohan
|
|
|
|
|
Check out the System.Text.RegularExpression.Regex class. You can use regular expressions to find date patterns. For more information, see this article[^].
|
|
|
|
|
As Judah said, you can use a regular expression.
You have to decide what date formats you will accept, as there is no way that you can extinguish any possible date format.
For example a string like "Our quest began in the third day in the fourth month in the year of the lord 1623." is clearly a reference to an exact date, but it's rather hard to write a program that will recognise it.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks guys, it helped me.
Mohan
|
|
|
|
|
Hi,
I've written a few programs and have never come accross this before:
<br />
public Main()<br />
{<br />
InitializeComponent();<br />
bool startupCheckValue = true;<br />
startupCheckValue = checkCorrectDirectory();<br />
if (!startupCheckValue)<br />
{<br />
this.Close();<br />
Application.Exit();
}<br />
checkDBHasVersionControl();<br />
getDBVersionNumber();<br />
}<br />
When startupCheckValue returns false, the program executes this.Close as well as Application.Exit but it just keeps going!
I've stepped through it and can't see why the app doesn't exit
Help please!
Glen Harvy
|
|
|
|
|
I recall there are issues with exiting the program inside the constructor of a form.
Perhaps you could set a flag in your constructor when you need to exit. Then override OnLoad, and if the flag is true, try exiting there.
|
|
|
|
|
Use an else statement so that checkDBHasVersionControl() and getDBVersionNumber() only execute on success and don't continue to execute any more code on the thread.
|
|
|
|
|
Thanks for the pointers .
I solved the problem by completing the if .. else statement as follows:
bool startupCheckValue = true;<br />
startupCheckValue = checkCorrectDirectory();<br />
if (!startupCheckValue)<br />
{<br />
Application.Exit();<br />
}<br />
else<br />
{<br />
checkDBHasVersionControl();<br />
getDBVersionNumber();<br />
}
and moved it into the Form_OnLoad process.
Cheers ..
Glen Harvy
|
|
|
|
|
i posted about how to pass my parameter to Crystalreports and a person reply to me by this code :
crystalReport11.SetDataSource(MyDataSet);
crystalReport11.SetParameterValue("PrintDate1", "2006/05/07"); // this line that error occured
crystalReportViewer1.ReportSource = crystalReport11;
but the following error shown me :
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
how to solve my problem and pass my parameter to crystalreports ?
thanks
|
|
|
|
|
I was looking for an approach to repaint a rectangle included on top of a control in the paint event handler. The paint event handler normally paints the whole control. If there is a rectangle on top of the custom control in the paint event handler that changes based upon which background image is provided for the control, how could I repaint that rectangle?
With Amar's assistance I was able to create and retrieve an extended property for the customized user control. Thus, the background image can be changed. However, now I need the rectangle in the paint event handler to be forcibly repainted.
I tried the ctrl.Invalidate() and ctrl.Refresh() and ctrl.Update methods in the _ctrl_BackgroundImageChanged(object sender, EventArgs e) event handler, but these approaches did not work. Any suggestions on how to repaint the clientRectangle that was created in the _ctrl_Paint event handler from the _ctrl_BackgroundImageChanged event handler?
I even tried to do the following:
public static Rectangle clientRectangle
private static void _ctrl_BackgroundImageChanged(object sender, EventArgs e)
{
Control ctrl = ((Control)sender);
ctrl.Invalidate(clientRectangle, true);
ctrl.Update();
ctrl.Refresh();
}
How do I repaint the entire control and any rectangle objects attached to the control?
-- modified at 17:09 Saturday 11th November, 2006
|
|
|
|
|
i need to know how i should load from image then read text on image
SUMA
|
|
|
|
|
Do some earching on OCR solutions.
---
b { font-weight: normal; }
|
|
|
|
|
can u help me more i searched many time on ocr tech. but i dont know which dll files supporrt this feature could u help???
SUMA
|
|
|
|
|
On my first search attemt I found a few...
http://www.xtras.net/categories/OCR/
http://www.freedownloadscenter.com/Programming/Components_and_Libraries/OCR__Net_Components.html
http://sourceforge.net/projects/tesseract-ocr/
http://www.leadtools.com/SDK/Document/Document-Addon-OCR.htm
http://www.programurl.com/ocr-net-components.htm
http://asprise.com/product/ocr/selector.php
http://www.softplatz.com/Soft/Development/Components-Libraries/OCR-Net-Components.html
http://www.download3k.com/Software-Development/Components-Libraries/Download-OCR-.Net-Components.html
Oh, and by the way, "plz help" is a really useless subject. Try to write a more descriptive subject the next time.
---
b { font-weight: normal; }
|
|
|
|
|
thx alot for your reply by the way to ask help is not something bad , any one start from scratch,and i tried many subject b4 but no responsed
thx again and sorry if title bothered u.
SUMA
|
|
|
|
|
suma12382 wrote: to ask help is not something bad
Of course not, but it has nothing to do in a subject line. Almost every thread here is about someone who asks for help, so the information has no value what so ever to distinguish the thread from other threads.
suma12382 wrote: and i tried many subject b4 but no responsed
I don't think that has much to do with the subject line. It's more likely because you don't even bother to try to write proper english. Txtspk is rather frowned upon in serious message boards, and some people simply ignore messages that contains "words" like "u", "plzzzzzz", "b4", "thx".
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for your comments,i will do it next time inshalla
SUMA
|
|
|
|
|
I'm pulling a lot of hair here - not much left, so kindly help.
I am trying to read and modify the contents of two tags (LoadBehavior and CommandPreload) in the following XML:
----------------
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
<Addin>
<FriendlyName>someaddin</FriendlyName>
[...]
<LoadBehavior>1</LoadBehavior>
<CommandPreload>1</CommandPreload>
[...]
</Addin>
</Extensibility>
----------------
My knowledge: I have a rough idea of what XML is, have no idea of the purpose of namespaces (other than making me hate XML more), and got the XML loaded into an System.XML.XmlDocument (yay!)
My problems:
============
(a) "navigation" in the presence of the namespace. Currently I do
---------------------
string nsname = "http://schemas.microsoft.com/AutomationExtensibility";
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("xx", nsname);
node = xmlDoc.SelectSingleNode("/xx:Extensibility/xx:Addin/xx:LoadBehavior", nsmgr);
this works, but having to prefix "xx" to every element in the path seems counterintuitive, and make writing generig methods a pain. Any better way? (note that I have to live with the namespace)
(b) Replacing an element
----------------------
I want to modify these elements, but want to create them if they are not present.
Currently, I do:
XmlNode parent = xmlDoc.SelectSingleNode("/xx:Extensibility/xx:Addin", nsmgr);
if (parent != null)
{
node = xmlDoc.SelectSingleNode("/xx:Extensibility/xx:Addin/xx:CommandPreload", nsmgr);
if (node == null)
{
node = xmlDoc.CreateElement("CommandPreload", nsname);
parent.AppendChild(node);
}
node.InnerText = preload.Value ? "1" : "0";
}
That seems utterly verbose, as I have t mix in my own application logic, and my solution to getting the namespace right makes putting this into an isolated function utterly tricky.
|
|
|
|
|
I have a picture box, on which I detect mousemove events, and have the user draw on the picture box. Currently, I can save the image, but it's just plain white, without the actual drawing, any ideas where Im going wrong?
[CODE:]
private Graphics m_objGraphics;
private void pb_white_board_MouseMove(object sender, MouseEventArgs e)
{
Rectangle rectEllipse = new Rectangle();
if (e.Button != MouseButtons.Left) return;
rectEllipse.X = e.X - 1;
rectEllipse.Y = e.Y - 1;
rectEllipse.Width = 3;
rectEllipse.Height = 3;
m_objGraphics.DrawEllipse(System.Drawing.Pens.Black, rectEllipse);
Brush blackBrush = Brushes.Black;
m_objGraphics.FillEllipse(blackBrush, rectEllipse);
}
private void btn_save_whiteboard_Click(object sender, EventArgs e)
{
Bitmap bitmap = new Bitmap(pb_white_board.Width, pb_white_board.Height);
pb_white_board.DrawToBitmap(bitmap, new Rectangle(0, 0, pb_white_board.Width, pb_white_board.Height));
m_objGraphics.Save("image1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
Thanks, Ben.
|
|
|
|
|
Two things...
1 - You are not dwawing on a PictureBox and
2 - You are trying to fetch drawn image from the PictureBox where painting has not taken place...
Cheers
|
|
|
|
|
Where is m_objGraphics created? I guess that you're creating the Graphics object somewhere during initialization of your code and then use it later, which is a big no-no!
To do it correctly you have to call methods on a Graphics object you get from the Image displayed in the PictureBox:
private void pb_white_board_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left) return;
Rectangle rectEllipse = new Rectangle(e.X - 1, e.Y - 1, 3, 3);
using (Graphics g = Graphics.FromImage(pb_white_board.Image))
{
g.DrawEllipse(System.Drawing.Pens.Black, rectEllipse);
g.FillEllipse(System.Drawing.Brushes.Black, rectEllipse);
}
pb_white_board.Invalidate();
}
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks, works a treat now
|
|
|
|
|
hi
i am use VC# 2005 and i want to connect to sqlserver 2000 from client to server,when i want to add datasource to my app and enter server name to
specific textbox and click Test connection the following error shown me :
Login failed for user 'VAZIRI-B8765F7F\Guest'.
I use Trusted Connection for connect to server
How to solve my problem ?
very thanks
|
|
|
|
|
Hi,
Are you sure that the credentials you supplied are correct ? (User name and password).
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hi
When you use trusted connection it means that you are connectiong to sql server using windows authentication which means that you are connectiong using the user name that you have logged on with.(In this case Guest user)
therefore you should define the guest user in your SQL Server.
If you like you can use user and password keywords in your connection string to use Sql authentication instead of a trusted connection then you can use a sql server user (for example sa) to connect to Sql Server
Regards
|
|
|
|