|
Hello all,
Does anyone have source code for parsing a person's name? For example:
Dr. John Q. Smith III would be parsed into:
var.Title = "Dr."
var.FirstName = "John"
var.MiddleName = "Q."
var.LastName = "Smith"
var.Generation = "III"
or Smith, John Quincy would be parsed into:
var.Title = ""
var.FirstName = "John"
var.MiddleName = "Quincy"
var.Lastname = "Smith"
var.Generation = ""
or Mr. Jose N. Del Valle would be parsed into:
var.Title = "Mr."
var.FirstName = "Jose"
var.MiddleName = "N."
var.Lastname = "Del Valle"
var.Generation = ""
Thanks all.
|
|
|
|
|
I would have a look at the String.Split method
|
|
|
|
|
here's an example to help you :
VB:
<font color="blue">Private</font> void richTextBox1_MouseMove(<font color="blue">Object</font> sender,System.Windows.Forms.MouseEventArgs e)
{
}
<font color="blue">Private</font> void button1_Click(<font color="blue">Object</font> sender, System.EventArgs e)
{
<font color="blue">Try</font>
{
string str="Mr. D Sysop";
string title=str.Split(<font color="darkgreen">' ')[0];</font>
string initial=str.Split(<font color="darkgreen">' ')[1];</font>
string surname=str.Split(<font color="darkgreen">' ')[2];</font>
string result = "Title: " + title + "\n" + "Initial: " + initial + "\n" + "Surname: " + surname;
MessageBox.Show(result);
}
<font color="blue">Catch</font>
{
System.Exception f=new System.Exception();<font color="#006400">
MessageBox.Show(f.Message.ToString());
}
}
hope that helps a little
<font color="blue">Private void</font> ExpectingTwins(<font color="blue">string</font> twins)
{
<font color="blue">switch</font>(twins)
{
<font color="blue">Case</font> ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
<font color="blue">break</font>;
}
}
|
|
|
|
|
WHy are those 2 guys throwing people off track?
You need to use some RegEx here! But that mite not be 100% as per your example 2, unless you can gaurantee the existanse of the ',' in there.
Here is something you can use perhaps:
((?<title>[A-Z][a-zA-Z]{1,4}\.)\s)?(?<fnames>([A-Z][a-zA-Z]*|[A-Z]\.)\s){1,3}?(?<lastname>[A-Z][a-zA-Z\-\s]+)
This wont work for 2nd case those but you could consruct another RegEx string on detection of a ',' in the string.
Cheers
|
|
|
|
|
Hi,
How can I use a memorystream in my richtextbox?
Now I do this, but it gives me a runtime error.
(In the real case I load a template of a letter in a string, do some replacements and then I want to show the results in a richtextbox. The string with the template I don't want to save it before I show it in the richtextbox. I want to save it only after I saw it in the richtextbox - there for the use of the memorystream)
string str = "abcdef";
this.TxT01 = new System.Windows.Forms.RichTextBox();
MemoryStream m = new MemoryStream();
for(int i=0;i< str.Length;i++)
{
m.WriteByte((byte)str[i]);
}
this.TxT01.LoadFile(m,RichTextBoxStreamType.RichText);
What I do wrong??
Thanks in advance for the help.
|
|
|
|
|
Hello there,
does anybody know how to find out the cursor position
in pixels (for example relative to the upper left corner)
in a Windows Forms TextBox?
I want to show a ListBox at that position, when the user
presses the OemPeriod key...
Thanks a lot.
brian
|
|
|
|
|
Sorry, but I didn't mean the mouse cursor,
but that "blinking input cursor"...
Thanks a lot.
brian
|
|
|
|
|
Very well, i've found it.
Thanks a lot.
brian
|
|
|
|
|
hi,I wonder wheather mshtml support editmode,and how to edit.Thanks.
|
|
|
|
|
Use the designMode property of the IHTMLDocument2 interface.
Here is some sample code. It assumes that:
1)You have added a reference to mshtml.tlb.
2) You have a WebBrowser control named webBrowser on your form.
IHTMLDocument2 HtmlDoc=(IHTMLDocument2)webBrowser.Document;
HtmlDoc.designMode="On";
And you're set! Remember that if the user navigates to a new page, the designMode property must be set again.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thank you.Now I want every selected element has border with BorderWidth 1mm,how can I do?
|
|
|
|
|
I want make a resources editor.I could create every component of resources file.But I want it is showed as design mode.What can I do?
|
|
|
|
|
There's a LOT of code involved in something like this. Check out SharpDevelop[^] for an example.
John
"We want to be alone when we hear too many words and we feel alone when it has been a while since anyone has spoken to us." Paul David Tripp -- War of Words
|
|
|
|
|
|
All I want to do is:
I want to make a win32 DLL that takes two LPWSTR's. One [in], one [out]. That's ALL! The problem is, when I call it from C#, the out string is always unchanged. I know this must be simple to do- interop can't suck this bad. Here is my code:
/// In the DLL:
extern "C" {
__declspec(dllexport) void transformIt(LPWSTR,[out] LPWSTR);
void transformIt(LPWSTR markup,[out] LPWSTR changed) {
changed= L"SOME STUFF";
}
}
// The Interop and the call:
[System.Runtime.InteropServices.DllImportAttribute("mydll.dll")]
private static extern void transformIt(
[MarshalAs(UnmanagedType.LPWStr)] string markup,
[Out,MarshalAs(UnmanagedType.LPWStr)] out string changed) ;
string stuff="wefwefw";
string changed; //also tried string changed="",changed=null, and a StringBuilder
transformIt( stuff, out changed);
Console.WriteLine(" >>>>>>>>>>>>>>> " + changed); //empty
I've tried this with a StringBuilder, I've tried with "ref" instead of an "out". No error is thrown, even when I do a try catch block. I know it's finding the DLL ok, becaause I made another test method that just returns an int and it worked. why why why why why why why
Please tell me it's me that sucks and not interop.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Have you tested your DLL in a non .Net environment? Maybe something is just not right with the DLL.
|
|
|
|
|
Well like I say, I tried making a simple function that just returns an int, in the same dll, and calling that from dot net and it worked fine.
Hey can you tell me if I'm assigning the LPWSTR properly? Do I have to do like memory alloc or something, or make a char array? The compiler didn't throw any errors..
thanks
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
It never gets called!?
If I override a label control then its OnPaint is getting called but not for a textbox, why is it so?
|
|
|
|
|
Some of the .net controls are drawn directly by windows and bypass the .net events. Override the WndProc function and handle thw WM_whatever you need there. Make sure you pass any messages you don't want to the base WndProc function. I had to do this on a toolbar.
|
|
|
|
|
I have various custom controls derived from UserControl that appear in modal forms. Within Dialogs the arrow keys are an alternate form of tab control i.e they move to the next control in the direction of the arrow within the current container ( this is standard windows behaviour I think ).
The trouble is I want to be able to respond to arrow keys in one of these controls. No key event is generated ( or sent to me ). Even overriding WndProc and checking for WM_ messages that way doesn't work.
I notice that list boxes etc are able to get these key events.
Any ideas ?
-Duncan
dmeech AT riverdeep DOT net
|
|
|
|
|
Hi Everyone,
Question: How would I test if someone was holding control while they pressed enter in a textbox?
I'm currently doing this:
int nReturn = Keys::Return;
int nControl = Keys::Control;
int nData = nReturn + nControl;
if (e->KeyData == nData) Now this code works, but you have to press enter twice while you're holding down control. Does anyone know why? Am I doing something wrong in the code? Another quick question, how would I do all code in one if condition? I tried:
if (e->KeyValue == Keys::Return & Keys::Control) but get this warning:
warning C4806: '&' : unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant if I put brackets around Keys::Return & Keys::Control it gets rid of the waring, but it still doesn't execute the code in the if block.
I know my code is in MC++, but if you could help (just give your response in C#) it would be very appreciated.
Thanks!
- monrobot13
|
|
|
|
|
Use the BitWise OR operator ('|') not AND ('&')
<a TITLE="See my user info" href=http:
|
|
|
|
|
Now that I think about it that makes a lot more sense. It works now, but I still have to press enter twice for it to actually go into the correct block. Any idea's on that?
Thanks!
- monrobot13
|
|
|
|
|
How do I convert a double value to an byte array (byte[8]) and the reverse from byte array till a double value?
In C++ we may take a memcpy to an char array and cast the array to a float!
|
|
|
|
|
Take a look at Convert class, especially ChangeType method.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|