|
It would be better if you posted part of the code that you are actually using, instead of posting some other code that does not quite do the same as what your actual code does.
The code that you posted does not do what you say that it does. Instead it will put the string "Sending File....\r\nLine 1 of 3Line 1 of 3Line 1 of 3Line 1 of 3" in the text box. The Remove call will not change the string at all, as it doesn't assign the result back to the Text property.
If you want to keep part of the string, use the Substring method to get that, and concatenate with the new string:
textBoxConsole.Text = "Sending File....\r\n";
int len = textBoxConsole.Text.Length;
for (int i = 1; i <= 3; i++) {
textBoxConsole.Text = textBoxConsole.Text.Substring(0, len) + "Line 1 of 3";
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
The code in the application is very similar, except that it calls methods from other files that return strings. These methods communicate with microprocessors and other peripherals. This is code I have made simple and have been debugging with the same problem, remember keep it simple?
Actually the code will put the string:
"Sending File....\rLine 1 of 3"
the remove command removes the "\n" because the text string has indexes for the "\" even though they are not counted separately in the text.Length.
I will try the code you provided, it looks like the best recommendation thus far.
Thanks.
|
|
|
|
|
asquaredtech wrote: The code in the application is very similar, except that it calls methods from other files that return strings. These methods communicate with microprocessors and other peripherals. This is code I have made simple and have been debugging with the same problem, remember keep it simple?
If you want to make a simpler code to demonstrate the problem, you have to make a code that actually does demonstrate the problem. The code that you posted didn't do that.
asquaredtech wrote: Actually the code will put the string:
"Sending File....\rLine 1 of 3"
No, it wont. As I explained, if the code would have assigned the result of the Remove call to the Text property it would have produced that result, but the code doesn't do that.
asquaredtech wrote: the remove command removes the "\n" because the text string has indexes for the "\" even though they are not counted separately in the text.Length.
No, it would remove the '\n' character because you are sending the wrong index to the method. The string does not contain indexes for the escape characters used to specify the string literal.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I am a noob working a webpage, i wanna pass multiple values from a select box in a query string so that a report may be generated any one can help me please. So basically, if the user enters only one value, only 1 report is queried if they entered more than 1 then more than one report is generated one after another. this is the code i already have, it only make one query to the database now. I want the reports to be created one below the other.... and so on.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SealRegister
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string connstring = @"Data Source=FGVMDEVSVR;Initial Catalog=FGBInvestment;uid=sa;pwd=Wizard1;";
SqlConnection conn = new SqlConnection(connstring);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_getTransfer";
SqlParameter parInput1 = cmd.Parameters.Add("@TRANSFER_ID", SqlDbType.Int);
parInput1.Direction = ParameterDirection.Input;
parInput1.Value = Request.QueryString["TRANSFER_ID"];
conn.Open();
SqlDataReader dtaReader;
dtaReader = cmd.ExecuteReader();
while (dtaReader.Read())
{
lblIMID.Text = Convert.ToString(dtaReader["IMID"]);
lblDESCRIPTION.Text = Convert.ToString(dtaReader["DESCRIPTION"]);
lblAMOUNT.Text = Convert.ToString(dtaReader["AMOUNT"]);
lblAMOUNT_TRANSFER.Text = Convert.ToString(dtaReader["AMOUNT_TRANSFER"]);
lblCONSIDERATION.Text = Convert.ToString(dtaReader["CONSIDERATION"]);
lblCURR.Text = Convert.ToString(dtaReader["CURR"]);
lblCons_Curr.Text = Convert.ToString(dtaReader["Cons_Curr"]);
lblNAME1.Text = Convert.ToString(dtaReader["CMF_NAME_1"]);
lblNAME2.Text = Convert.ToString(dtaReader["CMF_NAME_2"]);
lblADDR1.Text = Convert.ToString(dtaReader["CMF_ADDR_1"]);
lblADDR2.Text = Convert.ToString(dtaReader["CMF_ADDR_2"]);
lblADDR3.Text = Convert.ToString(dtaReader["CMF_ADDR_3"]);
lblADDR4.Text = Convert.ToString(dtaReader["CMF_ADDR_4"]);
}
dtaReader.Close();
conn.Close();
}
catch (Exception Ex)
{
lblCONSIDERATION.Text =Ex + "\n\n\nAn SQL error occurred when trying to retrieve Param Field Info. Please contact Admin";
}
finally
{
}
}
}
}
Ferron
|
|
|
|
|
ferronrsmith wrote: So basically, if the user enters only one value, only 1 report is queried if they entered more than 1 then more than one report is generated one after another.
What do you mean report here?? Is it a crystal report? I dont see any report binding code.
I would appreciate if you elaborate your requirement.
Cheers,
Sudhanva
|
|
|
|
|
i am cheap, can't afford crystal, lol. I wanna create a form that grabs data from a database and insert it in my layout, the problem i am having is that i want to grab multiple records from the database and display it. Three per page.
Ferron
|
|
|
|
|
ferronrsmith wrote: I wanna create a form that grabs data from a database and insert it in my layout
Instead create a usercontrol (which should have your forms' controls) to bind the data, and put a for loop for number of querystring items, and call the usercontrol and bind the data.
That should solve your problem.
Cheers,
Sudhanva
|
|
|
|
|
I need to take a .docx file or .doc and make it into HTML. Here is an example of before and after of what I need.
.doc or .docx file
Interviewer: Question
Interviewee: Answer
HTML
<div class="interview">Interviewer</div>
<div class="QorA">Question</div>
<div class="interview">Interviewee</div>
<div class="QorA">Answer</div>
If anyone could help me out on starting to write this.
Thanks!
|
|
|
|
|
I am used to C++ more than C#.
In C++ you have header files and you have the ability to declare states. For example, you can declare a series of unsigned integers to be for a variety of different states to later use in switch statements or if-then statements.
Since C# does not have the same sort of structure with header files, how would I impliment a simular functionality in C#?
The reason why I want to use UINT is because you can do that super cool bit-wise and and or with them. Remember those good ol' days? You could define four different conditions like this:
UINT state_001 2
UINT state_002 4
UINT state_003 8
UINT state_004 16
Then a variable can be any one state or any combination of states. To assign a variable a particular state, you do a bitwise and to the variable. To see if the variable was set to any of the states, you do a bitwise or.
How would that look like in Visual C#?
|
|
|
|
|
It would look good, and a lil' bit more readable than C++.
I are troll
|
|
|
|
|
Use an enum with the [Flags] attribute set for a bitfield. Here's a snippet from MSDN:
// A bit field or flag enumeration of harvesting seasons.
[Flags]
public enum Seasons
{
None = 0,
Summer = 1,
Autumn = 2,
Winter = 4,
Spring = 8,
All = Summer | Autumn | Winter | Spring
}
Hope this helps!
Jon
|
|
|
|
|
Xarzu wrote: How would that look like in Visual C#?
It would look better.
You use an enum, which gives it more structure. This will also give you the possible values to use right in the intellisense, so you don't have to wade through loads of header files to find out which constants you can use.
[Flags]
public enum Feeling {
Happy = 1,
Hungry = 2,
Free = 4,
Cold = 8
}
The Flags attribute enables you to perform bitwise operations on the enum values:
Feeling xarzu = Feeling.Happy | Feeling.Hungry;
if ((xarzu & Feeling.Happy) != 0) MessageBox.Show("Xarzu is happy.");
The data type that the enum uses by default is int , as that's the most efficient type. You can specify a different type like an uint if you like, but there is rarely any reason for that.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
viterbi algorithm in c#
can any one explain wats happening in the code
i need working of this code,,, antyone pls
using System;
using System.Collections.Generic;
using System.Text;
namespace Viterbi
{
public class ForwardViterbi
{
// The Class Globals
string[] states;
string[] observations;
double[] startProbability;
double[,] transitionProbability;
double[,] emissionProbability;
double scaleFactor;
//Computed Variables
int[] vPath; //The Viterbi Path
double[] vProbs;
//----------------------------------------------------------------------
// The Getters or Accessors
public int[] VPath
{
get { return vPath; }
}
public double[] VProbs
{
get { return vProbs; }
}
//----------------------------------------------------------------------
//Constructor
public ForwardViterbi(string[] states, string[] observations, double[] startProbability, double[,] transitionProbability, double[,] emissionProbability, double scaleFactor)
{
this.states = states;
this.observations = observations;
this.startProbability = startProbability;
this.transitionProbability = transitionProbability;
this.emissionProbability = emissionProbability;
this.scaleFactor = scaleFactor;
}
//----------------------------------------------------------------------
//The Methods
public void Process(int[] problem)
{
double[,] T = new double[states.Length, 3]; //We will store the probability sequence for the Viterbi Path
vPath = new int[problem.Length];
vProbs = new double[problem.Length];
//initialize T
//------------------------------------------------------------------
for (int state = 0; state < states.Length; state++)
{
T[state, 0] = startProbability[state];
T[state, 1] = state;
T[state, 2] = startProbability[state];
}
for (int output = 0; output < problem.Length; output++)
{
double[,] U = new double[states.Length, 3]; //We will use this array to calculate the future probabilities
Console.WriteLine("\nTesting hypothesis {0} ({1})", output, observations[problem[output]]);
double highest = 0;
for (int nextState = 0; nextState < states.Length; nextState++)
{
double total = 0;
double argMax = 0;
double valMax = 0;
Console.WriteLine(" Estimating probability for future state {0} ({1})", nextState, states[nextState]);
for (int state = 0; state < states.Length; state++)
{
Console.WriteLine(" The testing state is {0} ({1})", states[state], state);
double prob = T[state, 0];
double v_path = T[state, 1];
double v_prob = T[state, 2];
double p = emissionProbability[state, problem[output]] * transitionProbability[state, nextState] * scaleFactor;
prob *= p;
v_prob *= p;
total += prob;
if (v_prob > valMax)
{
valMax = v_prob;
argMax = nextState;
}
Console.WriteLine(" VProbability of {0} is {1} with scale {2}^{3}", states[nextState], v_prob, scaleFactor, output + 1);
if (v_prob > highest)
{
highest = v_prob;
vPath[output] = nextState;
vProbs[output] = v_prob;
}
}
U[nextState, 0] = total;
U[nextState, 1] = argMax;
U[nextState, 2] = valMax;
}
T = U;
Console.WriteLine("The highest probability was {0} in state {1} (scale factor of {2}^{3})", highest, states[vPath[output]], scaleFactor, output + 1);
}
//Apply SumMax
double Total = 0;
double ValMax = 0;
for (int state = 0; state < states.Length; state++)
{
double prob = T[state, 0];
double v_path = T[state, 1];
double v_prob = T[state, 2];
Total += prob;
if (v_prob > ValMax)
{
ValMax = v_prob;
}
}
Console.WriteLine("\nAnalysis: Total probability (sum of all paths) for the given state is :: {0}\nThe Viterbi Path Probability is :: {1}", Total, ValMax);
Console.WriteLine("The above results are presented with a scale factor of {0}^{1}", scaleFactor, problem.Length);
}
}; // end Forward Viterbi Class
}
|
|
|
|
|
No-one is going to read all of this, or do your homework for you. How about you tell us which line is not doing what you expect ? Have you spent some time in the debugger to see where the code is not following the logic you hoped for ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
dear friend
i spent time and studied.. but these lines i don understand the logic... can u help me pls
if (v_prob > valMax)
{
valMax = v_prob;
argMax = nextState;
}
Console.WriteLine(" VProbability of {0} is {1} with scale {2}^{3}", states[nextState], v_prob, scaleFactor, output + 1);
if (v_prob > highest)
{
highest = v_prob;
vPath[output] = nextState;
vProbs[output] = v_prob;
}
}
U[nextState, 0] = total;
U[nextState, 1] = argMax;
U[nextState, 2] = valMax;
}
T = U;
Console.WriteLine("The highest probability was {0} in state {1} (scale factor of {2}^{3})", highest, states[vPath[output]], scaleFactor, output + 1);
}
//Apply SumMax
double Total = 0;
double ValMax = 0;
for (int state = 0; state < states.Length; state++)
{
double prob = T[state, 0];
double v_path = T[state, 1];
double v_prob = T[state, 2];
the quieter u become more u hear
|
|
|
|
|
How about no scott? Scotty says no? howbowudoee? Ladies and gentlemen scotty don't.
|
|
|
|
|
Hi,
The Viterbi algorithm is an interesting one, IMO its working is best explained and understood using
several graphics, rather than code. Anyway it is beyond the scope of a forum like this one, you would
better look it up in a specialized book, such as a digital communications course.
Once you fully understand the allgorithm, I suggest you take a really really simple test case,
and work it out by hand, then run it through the program you want debugged, and compare the results
step by step. Don't expect too much help from this forum, unless you prove you understand and really
tried, but got stuck at a very specific point.
|
|
|
|
|
Luc Pattyn wrote: Once you fully understand the allgorithm..
..write an article about it and post it here!
Luc Pattyn wrote: Don't expect too much help from this forum
Sad, but true. "Gimme codez, urgent" makes one cynical.
The noise is going up in this forum, and it's killing the music..
I are troll
|
|
|
|
|
Eddy Vluggen wrote: "Gimme codez, urgent" makes one cynical.
The noise is going up in this forum,
That was not the point, the topic is rather complex an not very suited for a text-only forum
that focuses on small programming issues.
|
|
|
|
|
Fortunately, one can use pictures when submitting an article
I are troll
|
|
|
|
|
I am writing a windows service in c# and am loading a crystal report. I need to export this report as a jpg file to disk or to take some kind of image stream which I can load into a bitmap or image object. I can export to a PDF but this is no use to me.
Any ideas?
|
|
|
|
|
Have never had the need to use Crystal Reports myself but this link[^] looks like it might have the answer.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi thanks for the reply. but.. the link takes me to a page describing how to "export crystal as image" perhaps you gave me wrong link? or else my english writing is a total failure. i need help on how to list parameter values dynamically created by the report.
Br
Tomas
If it' stuck, DO NOT pull harder!
|
|
|
|
|
c0ax_lx wrote: help on how to list parameter values dynamically
That's not the question you asked!:
c0ax_lx wrote: I need to export this report as a jpg file to disk or to take some kind of image stream which I can load into a bitmap or image object.
I'd start a new thread seeing as it's a totally new question.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
D'uh! i'm really sorry! this wasnt even my post! not used to see crystal report questions here *sigh*. well. You are totally correct, your post is the answer to the question.
so i'll just shut up now and try to find my own post.
hmm. i feel stupid.
Rgds
Tomas
If it' stuck, DO NOT pull harder!
|
|
|
|
|