|
Add a whitespace and an "end-of-line" indicator:
Dim regExp As Regex = New Regex("\s(\d{5})$") And include the whitespace back in your replacement string.
And in future: post VB in the VB forum, and C# in the C# forum?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It was exactly a C# question and not VB. I wonder why this simple question have made all nervous! it was related to Fuzzy Logic and Fuzzy Expert Systems.
Anyway, thanks a lot for your all answers.
|
|
|
|
|
You have replied to someone else's question. The question that was asked here was written in VB.
|
|
|
|
|
If you look at the question I answered, you will see it is written in VB, not C#...
Dim regExp As Regex = New Regex("(\d{5})")
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
how can we convert a code written in c# into matlab??
any idea?
|
|
|
|
|
Already answered in the .NET forum. Crossposting is discouraged.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
can any help..
in this code the first letter of any string in the problem SEND + MORE = MONEY should not be 0. but its showing showing zero..
how to do this???
please help....
namespace CryptArithmetic
{
public partial class Form1 : Form
{
char[] s1 = new char[10];
char[] s2 = new char[10];
char[] s3 = new char[10];
int[] assinged = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
char[] c = new char[11];
int[] val = new int[11];
int topc = 0;
public Form1()
{
InitializeComponent();
}
private void btn_ok_Click(object sender, EventArgs e)
{
label4.Text = "";
s1 = textBox1.Text.ToCharArray();
s2 = textBox2.Text.ToCharArray();
s3 = textBox3.Text.ToCharArray();
int flag=0;
//to check if no letter is repeated and store unique letters in array c[] from s arrays
for(int i=0;i<s1.length;i++)
{
="" for(int="" j="0;j<=topc;j++)
" if="" (s1[i]="" !="c[j])
" (i="=" 0)=""
="" i++;="" flag="1;
" }
="" else
="" break;
="" if(flag="=1)
" c[topc++]="s1[i];" i="0;i<s2.Length;i++)
" if(s2[i]!="c[j])
" if(s3[i]!="c[j])
" }
="" (solve(0,="" assinged)="=1)
" label4.text="" +="\n" c[i]+"---="">"+val[i].ToString() + "\n";
}
else
label4.Text = "Sorry";
}
//-------------------end of getdata-----------------
int solve(int ind,int []temp1)
{
int [] temp2 = new int[10];
int flag=0;
for(int i=0;i<10;i++)
{
if(temp1[i]==0)
{
for(int j=0;j<10;j++)
temp2[j]=temp1[j];
temp2[i]=1;
val[ind]=i;
if(ind==(topc-1))
{
if(verify()==1)
{
flag=1;
goto exit;
}
}
else{
if(solve(ind+1,temp2)==1){
flag=1;
goto exit;
}
}
}
}
exit :
if(flag!=0)
return 1;
else
return 0;
}
int verify()
{
long n1=0,n2=0,n3=0;
long power=1;
char ch;
int i=s1.Length-1;
int in1;
while(i>=0)
{
ch=s1[i];
in1=0;
while(in1!=topc)
{
if(c[in1]==ch)
break;
else
in1++;
}
n1+=power*val[in1];
power *=10;
i--;
}
power=1;
i=s2.Length-1;
while(i>=0)
{
ch=s2[i];
in1=0;
while(in1!=topc)
{
if(c[in1]==ch)
break;
else
in1++;
}
n2+=power*val[in1];
power *=10;
i--;
}
power=1;
i=s3.Length-1;
while(i>=0)
{
ch=s3[i];
in1=0;
while(in1!=topc)
{
if(c[in1]==ch)
break;
else
in1++;
}
n3+=power*val[in1];
power *=10;
i--;
}
if(n1+n2==n3)
return 1;
else
return 0;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void btn_cancel_Click(object sender, EventArgs e)
{
textBox1.Text = " ";
textBox2.Text = " ";
textBox3.Text = " ";
label4.Text = "";
}
}
}
|
|
|
|
|
Try the built-in encryption routines, they'll be a bit safer than shuffling some values. If you want help with this specific algo, you'll probably have to explain some more; which encryption-algo are you trying to implement?
Also, you'd like to edit your post and put the code between "pre" tags to improve readability.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I didn't read your code, but just in case, in C# (and almost every C base language) when counting an array/index, the very first position of the array will be 0/zero, it is common to see something like this in a for
for (i = 0:i<=Array.Lenght -1;i++){
}
where you substract 1 to the Lenght of the array because even though the array length is 10 you start counting at 0 (0,1,2,3,4,5,6,7,8,9)
I want to die like my grandfather- asleep, not like the passengers in his car, screaming!
|
|
|
|
|
I have 2 text box in form 1 and 4 button + 1 text box in form 2
how I can show the form 1 text box in form 2 and use from their
value.(this is a calculator)
|
|
|
|
|
You can pass it to the form via a setter method, or use a delegate to communicate between them. It rather depends on the structure of your application.
|
|
|
|
|
how can i use from setter method ?
|
|
|
|
|
Define a string property in the Form class and use that.
public string ToBePassed
{
get; set;
}
form2.ToBePassed = TextBox1.Text;
|
|
|
|
|
.
modified 28-Jan-19 5:55am.
|
|
|
|
|
Please use the forum at the end of the article.
|
|
|
|
|
I've got a Timer delegate described method as preparation for a double recursion work and second method with tiny optimized recursion only. I need to execute the recursion in async thread too. But NET.Framework dont do that, only do async preparation method and no recursion method.
C# code
using System.Threading.Timer
...
private void button10_Click(object sender, EventArgs e)
{//Timer
Elem ss = new Elem();//Elem is a structure.
ss.a = "string1";
ss.b = "string2";
TimerCallback timeCB = new TimerCallback(timerex);
System.Threading.Timer t = new System.Threading.Timer(timeCB, ss, 10000, 10000);
}
public static void timerex(object data)
{
string a1 = ((Elem)data).a;
string b1 = ((Elem)data).b;
MessageBox.Show(a1+" "+b1);
timerex2(a1,b1);
}
public static void timerex2(string s1,string s2)
{
MessageBox.Show("Method_in 2 "+s1+s2);
}
How to execute the recursion in async timer thread?
|
|
|
|
|
Ignoring that there isn't any recursion in your code, if I copy and paste your code into my app and try it - it works.
I get the first message box, then the second.
Then a delay, first message box, second message box.
Repeat until bored or I shut the app.
So what did you expect to happen?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Everything is correct. This is just a test, not a real program.To avoid any other mistake influences.
Did you get
MessageBox.Show("Method_in 2 "+s1+s2); ?
Execution of the second method timerex2(a1,b1);
Has to be doubling messaging every 10 sec. Ive got only 1 message,10 sec and again one.
ps Could be my computer problem-VS2013.4-NETF.4.5,W8.1,intel proc
Here is image
http://s58.radikal.ru/i162/1503/a7/95b9927aadee.jpg
modified 8-Mar-15 13:19pm.
|
|
|
|
|
As I said, I got both message boxes, with a ten second separation.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Since your message is missing:
"What shall i do? Report to Microsoft? Computer is clean, fresh reinstalled"
Um.
Having looked at your image, there are a few things you need to know...
A MessageBox is a modal dialog. That means that when you call the Show method, it doesn't return until the user (or the system) dismisses the dialog, normally by pressing a button.
So...this code:
string b1 = ((Elem)data).b;
MessageBox.Show(a1 + " " + b1);
timerex2(a1, b1);
Cannot call timerex2 until the dialog opened in the previous line has been closed.
This is not a bug: this is exactly what is supposed to happen. If you click on the "OK" button, you will get the second dialog, just as I did.
What are you trying to do?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You are right.
I put the MessageBox just as a checkpoint for new thread.Modal windows in new thread are not modal any more as for main thread.It was my fault with mixing modals as for local thread.
In normal situation i dont use messagebox.
My real fault was that description of delegate was inside in method. In end of method data was cleared and nothing happends.
But i fixed it already.
Thank you for help.
ps.Actually trying to fix it.
In local description doesnt need static method and it is working ok. In form class description ask static method
modified 8-Mar-15 16:58pm.
|
|
|
|
|
Abstract: first time I'm dealing with web service, soap, appurtenances, so forgive me ignorance absolute. (Also for the bad english)
I have a wsdl on a web server institutional written in java that does NOT contain the client and the various calls no header, but it always requires, for each call.
Problem: I create the client quietly with the endpoint, I connect to the web server responds to me and I read all the parameters (which I do not need anything) of the server. (So I created the tunnel)
Just try to make a call using any of the wsdl, type wsdl.result res = wsdl.getvalore (parameters), I always get errors due to the lack of the header in the message, for example: Private key is not in the X.509 certificate. (But NOT required private key to feel the support of the web service) or No Security Header.
Following the example of the soap message in XML. For the part BODY no problem, but how do I add the header? Thanks to everyone who can help me out.
Regards.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:mustUnderstand="1">
<wsu:Timestamp wsu:Id="TS-3">
<wsu:Created>2014-09-09T08:23:50.725Z</wsu:Created>
<wsu:Expires>2014-09-09T08:28:50.725Z</wsu:Expires>
</wsu:Timestamp>
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-00000000000000000000000000000000">qtgOKG92iPHI/XLXGxFmg6Vnqmdg=</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-4">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="soapenv"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#TS-3">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsse soapenv"/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>hK3A/dZmQfIGDx9p7/8zV31iWDQ=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>JlWXCRS6NEz9pl5gD9PBedQj6OMxBDXkLhIwGjncl4IsC1DzPoIVEJmIp/D679ba+pi692gvGpLn</ds:SignatureValue>
<ds:KeyInfo Id="KI-00000000000000000000000000000000">
<wsse:SecurityTokenReference wsu:Id="STR-00000000000000000000000000000000">
<wsse:Reference URI="#X509-00000000000000000000000000000000" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<scat:getPrescrizioneFirmata xmlns:scat="www.aaa.regione.it/Schemas/AAA_WEB/SERVICE/">
<scat:datiOperatore>
<scat:codStruttura>001001</scat:codStruttura>
<scat:codiceFiscale>PPPTTT00P01R000T</scat:codiceFiscale>
<scat:ruoloIstituzionale>Rrr000000</scat:ruoloIstituzionale>
</scat:datiOperatore>
<scat:datiApplicativo>
<scat:applDigest>gredfgggjnbhtdybvvhghggvvbvb=</scat:applDigest>
<scat:created>2014-09-09T10:23:522+0200</scat:created>
<scat:nome>ABC</scat:nome>
<scat:nonce>ZQJzbirixuhvfa8NtoQa</scat:nonce>
<scat:produttore>PIPPO</scat:produttore>
<scat:versione>20.03</scat:versione>
</scat:datiApplicativo>
<scat:identificativoRicetta>001001001001001</scat:identificativoRicetta>
</scat:getPrescrizioneFirmata>
</soapenv:Body>
</soapenv:Envelope>
|
|
|
|
|
You should post this in one of the Web development forums.
|
|
|
|
|
Ok, sorry.
|
|
|
|
|
Like the VS2013, can you design a form, add or remove the components above, right mouse button menus, and the Properties window.
|
|
|
|
|