Works fine for me in VS2013 Ultimate running .Net 4.5 console application.
I can access the matches
variable and it contains fox as expected... odd.
Works fine for me in VS2013 Ultimate running .Net 4.5 console application.
I can access the matches
variable and it contains fox as expected... odd.
No problem.
Is the restructure of the XML acceptable or did you need to keep it as it originally was? Hopefully it was as otherwise I am not sure it would be possible :)
If it is solved, please mark the question as solved :)
I have achieved the above using XSL 1.0, however your XML file structures are not the best and so I have done it using a modified structure. Let me know if this causes any issues and I will see if it can be adapted.
New input file, this had to be modified to group together the name and language code of each entry, just having one line next to another is not queryable using xsl.
<XML>
<Data>
<Name>shades</Name>
<Languagecode>555</Languagecode>
</Data>
<Data>
<Name>test1</Name>
<Languagecode>559</Languagecode>
</Data>
<Data>
<Name>test2</Name>
<Languagecode>557</Languagecode>
</Data>
</XML>
The lookup file, same as above, needed to group the data.
<Languages>
<Language code="555">
<Name>hindi</Name>
</Language>
<Language code="556">
<Name>tamil</Name>
</Language>
<Language code="558">
<Name>telugu</Name>
</Language>
<Language code="559">
<Name>malayalam</Name>
</Language>
<Language code="557">
<Name>bengali</Name>
</Language>
<Language code="554">
<Name>punjabi</Name>
</Language>
</Languages>
and finally the XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="lookupDoc" select="document('FULL_FILEPATH_HERE')" />
<xsl:template match="*">
<xsl:element name="XML">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="Data">
<xsl:element name="Data">
<xsl:element name="Name">
<xsl:value-of select="./Name/text()"/>
</xsl:element>
<xsl:call-template name="MakeSpanForCode">
<xsl:with-param name="code" select="Languagecode/text()" />
</xsl:call-template>
</xsl:element>
</xsl:template>
<xsl:template name="MakeSpanForCode">
<xsl:param name="code" />
<xsl:element name="Languagecode">
<xsl:value-of select="$lookupDoc/Languages/Language[@code = $code]/Name/text()" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Produces the following
<XML>
<Data>
<Name>shades</Name>
<Languagecode>hindi</Languagecode>
</Data>
<Data>
<Name>test1</Name>
<Languagecode>malayalam</Languagecode>
</Data>
<Data>
<Name>test2</Name>
<Languagecode>bengali</Languagecode>
</Data>
</XML>
Hi
Sorry for the delayed reply.
Is there the option to edit the layout of your Lookup file to start with? It could be improved in terms of how you structure it for clarity of querying.
Okay to start with I will point you in the right direction for what you want to do and then if you have issues post them back and we will look at them.
Work is absolutely mad for me today and its already half 6 in the evening and don't think I will be out of here before 8pm so will reply when possible.
Anyway...
// Greet the user.
Console.WriteLine("\n\tWelcome to Vegas Dice Roller!");
Console.WriteLine("\n\tLet's get started!");
Console.WriteLine();
// Start the loop for dice rolls, rolling two dice at a time
// ##You will make a while loop here which just uses the value 'true' so it never ends
// Generate the two values randomly (1 - 6, inclusive)
// ##See this link http://stackoverflow.com/questions/2706500/how-to-generate-random-int-number
// ##Store the numbers as parameters
// Call the ShowDice method, sending the two values into it, so it can display the roll
// ## Call ShowDice using the parameters made above. ie. ShowDice(paramNumOne, paramNumTwo)
// Ask the user if he wants to roll again.
// ##Write to the console like you have done at the start of program
// If he answers anything other than "Y" or "N", ask him again.
sResponse = Console.ReadLine().ToUpper();
while ((sResponse != "Y") && (sResponse != "N"))
{
Console.WriteLine("I'm sorry but I didn't understand your response.");
Console.Write("Would you like to roll again (Y or N)? ");
// Obtain user's response and store in the string variable
sResponse = Console.ReadLine().ToUpper(); // no change needed
}
// ##This …
You have posted a large block of code. What is your actual issue? Most on the forum don't have the time to try and guess the issue themselves.
What is the value of Book.TxtFileName
at present?
Just need to make sure it is a filepath ie C:\Desktop\nBook.txt
and it should be fine to save as a .txt
file
You're right!
I also now see this behaviour if I shorten the text contained in one of the variables.
The solution I used was the following (line 21):
public class Temp
{
public string Name;
public string HotKey;
public string Timer;
public string Message;
}
class Program
{
static void Main(string[] args)
{
Temp TempClass = new Temp();
string FilePath = @"D:\Users\MASKEW\Desktop\Test.xml";
TempClass.Name = "Na";
TempClass.HotKey = "Hot";
TempClass.Timer = "Timer";
TempClass.Message = "Message";
File.Delete(FilePath);
XmlSerializer writer = new XmlSerializer(typeof(Temp));
using (FileStream file = File.OpenWrite(FilePath))
{
writer.Serialize(file, TempClass);
}
}
}
This deletes the file and then re-creates it meaning there is no data corruption from the previous entries.
Can't seem to replicate your issue using the following test code:
public class Temp
{
public string Name;
public string HotKey;
public string Timer;
public string Message;
}
class Program
{
static void Main(string[] args)
{
Temp TempClass = new Temp();
string FilePath = @"D:\Users\MASKEW\Desktop\Test.xml";
TempClass.Name = "Name";
TempClass.HotKey = "HotKey";
TempClass.Timer = "Timer";
TempClass.Message = "Message";
XmlSerializer writer = new XmlSerializer(typeof(Temp));
using (FileStream file = File.OpenWrite(FilePath))
{
writer.Serialize(file, TempClass);
}
}
}
Any changes to the above to improve its accuracy?
The duplicate did exist Ket, as it was I who flagged it.
Set your combobox Text property to the default value you want to display.
If the selected index doesn't exist in the DB, set your SelectedIndex on the combo box to -1. This will revert it to your default text.
I don't get this behaviour when testing, the box remains blank after setting the index to -1 from another value (VS2012/.Net4.5).
I disagree with the downvote though, it is a better route than manually adding an item.
Please provide the code you are working with
MessageBox.Show()
requires it to be a WinForms project as far as I know (there could be ways around it like referencing the right DLLs)
I am starting to guess your project is console or service based?
I would have come up with the same as Fenrir() from looking at your code. The above is the correct code for your commented out section around a confirmation.
He just has omited code to save the record.
It is worth noting you never shut connections to the database, close the connection after each call, it could be causing a hidden error (though unlikely as it would be an exception)
I can't replicate your issue.
Works fine with:
Console.Write("Enter your text: ");
string Input = Console.ReadLine();
Input = Input.ToLower();
string Result = Input.Replace("remove", "");
Console.WriteLine("Edited text: " + Result);
Console.ReadLine();
Sentence: "There is one word to remove in this sentence"
Tested with "remove" and "removed", remove worked, removed didn't.
Can you upload your solution somewhere for me to download and look at? Can't see what would cause the error by eye.
Could you highlight which line the error occurs on, Tinstaafl is correct about the alternate way to change the value also though :)
I find it odd that you would get an object not initialised error in the code block you linked as it is specifically initialised on line 4 to be a new empty list.
You almost had it and had the correct idea moving the list declaration outside of the switch function, the small details are what caught you out though!
string board = "1";
// Here we declare an empty list called icons
List<string> icons = new List<string>();
switch (board)
{
// We then re-initialise the list depending upon case
case "1":
icons = new List<string>() { "!", "!", "N", "N", ",", ",", "k", "k", "b", "b", "v", "v", "w", "w", "z", "z" };
break;
case "2":
icons = new List<string>() { [Different String Set Here] };
break;
}
In the above code we declare the icon list once outside of the switch statement;
Within each case statement we simply re-instanciate the list with a new value set instead of fully re-defining it each time which was the original cause of the error.
IIRC, calling something along the lines of this.Refresh();
after line 135 will force the form's redraw event before the thread continues and sound plays.
Right so I've done some toying around this morning. Seems I misunderstood how the sound play works slightly. The .wav is played on its own thread automatically.
If no one else comes up with the code I will have a toy at work tomorrow if I get time and see if I can get a rough example done
The Sleep function will pause the current thread it is called on. As this is the UI thread from what I can see it will simply 'pause' the entire program for that amount of time.
You could use a background worker or second thread to handle the sound being played and then when you sleep that thread it would not impact the turning over of the cards on the main UI thread.
That is true they aren't cheap, forgot about import etc also as brought mine in the UK
100+ endorsements, of which a at least 7 in each category are from a subset of accounts that appeared about 7 months ago, endorsed him and upvoted, and then became inactive again and haven't been seen since.
i have about 18 years of expirience banging tables :P only reason i dont have a drumkit at home is because of how quiet my neighborhood is , and how much the neighbors would like to keep it that way. I played guitar , until the neck bent and now tunes drop even with half-hours strumming. :(
Get an electronic drum kit, I have a Roland one and you can play through headphones when needed or an amp.
My comment is UK based :)
Presume you did a fairly decent google yourself as you have a brain.. I can't find anything either, the User32.dll
is required for bringing the window to front as far as I can see, can find a process using the Diagnostics.Process
class or through the User32.dll
though.
Sadly they have invented VPN, so even if the offices are all magically shut due to something we can all still work :(
I can add my personal experiences here.
I did not go to University either after finishing Sixth Form.
I applied for a Higher Apprenticeship with Capgemini UK while in college along with the usual university applications. The HA programme does not require any prior knowledge of programming at all (however I also studied programming at sixth form) and offered a 10 week intensive course in the language they wished us to know (C# in my case) before dropping us straight into live projects with extensive support mechanisms in place.
I had an offer from my university of choice, Essex, to study computer science. I also however got the opportunity to work for Capgemini after being successful with my application to the programme and have been working for them for two years now. I will still be getting a degree through them over the five year programme at no expense to myself along with earning an alright salary (scaling up with progression through the company) and getting highly valuable industry experience in a Tier 1 consultancy firm.
Best move I have made in my life so far was declining university and doing what I do now, whereas people will be coming out of university with degrees approximately two years before myself I will have 3 years experience over them and nowadays companies look for that also with equal if not more value.
I can only speak from a UK point of view but I am certainly aware of a few companies …
The issue is that you are trying to set a byte[] to the value of the cell which is a string, this does not have a direct convert thus your cast does not work.
You will need to do a conversion first.
static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
The above will do this for you, I have obtained it from a simple google. Here is the source post on SO, credit goes to them for it.
Your issue lies in the <xsl:otherwise>
.
You are selecting the current node Application/Comment
with <xsl:apply-templates select="."/>
and then applying templates against it, triggering an infinite loop as this simply calls the same template over and over, eventually running out of memory causing the stack overflow you are seeing.
Tested this within Visual Studio debugging the XSL as best I could with the data provided and was able to recreate the issue.
Add a boolean that is set to true once the alarm is triggered, and adjust the alarm if-statements accordingly to only run when it is false?
Once the value falls back into the threshold it can be reset ready for the next time?
bomber was a Jewish Woman.
The bombs were pressure cookers left on site filled with nails. The FBI have no idea who is behind it.
Pretty sure I've read in the past ownership is taken to help fight against scraping sites
http://www.bbc.co.uk/news/world-us-canada-22160691
The count is at three, according to the second conference held regarding it.
ToS Snippet
Posts contributed to the community immediately become the property of DaniWeb upon submission
You are correct HiHe.
Note the first mention of column is singular and the second is plural. Is that mistake in the code?
I haven't tried it myself either, would presume the implementation is: dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
Hi Mark,
Hope all is well.
A quick google turned up the following two possible solutions you can try:
DataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
DataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
Pulled them off of SO, original link here
I am sure if you (LastMitch) live longer, you'd live happier.
Until that person is suffering from an incurable disease, at which point your logic is, at best, flawed.
Coming from somebody that is 21 and completely tea-total, you can look at drink/smoking etc from two points of view. Yes both are bad and put pressure on the health industry etc and may harm the body. But on the other hand it is somebodies way of relaxing and chilling out in the evening.
I for example easily spend 20+ hours a week playing video games when I'm not at work, this isn't the best for my health and damages my eyes over time, but it is what makes me happy and thus I do it to chill out. My parents like to have a glass of wine in the evening to relax, they don't consume excessively and its perfectly acceptable.
You for example Michael have alot of interest in sports it seems. While that is all well and good we have recently seen a professional footballer collapse from a heart attack, die and be revived, and live on when they are seen as peak physical condition. While the argument there that sport is good it can also be just as bad for you in terms of body overworked etc.
Everything has its downsides, its all about opinions.
TL:DR - Its all opinionated and nothing more.
Edit - Clarified footballer further, I am referring to 'Fabrice Muamba'
Screenshot one looks so very like the zoom issue.
Have you confirmed this table exists?
Just tried to reproduce this on Chrome Version 24.0.1312.57 m but it didn't occur for me.
I would say that is pretty much spot on for what you're trying to achieve.
Wouldn't you need to instantiate the class first and then call the .Insert()
method off the instanciated object? Obviously we can't see the full code so thats a guess but it could be the case.
I.e
TestClass TS = new TestClass(); //With any constructor you use
TS.Insert(Params...);
When running those figures I recieve:t
= 8.95430243255237E+23msg
= 149
I presume the issue is coming from the result of t
?
@tinstaafl using your suggestion just results in the two results above being flipped to negatives and values changed, i.e:t
= -9.22337203685478E+18msg
= -162
Tested using the code:
double v = 11;
double d = 23;
double n = 187;
double t = (long)Math.Pow(v, d);
Console.WriteLine(t);
Int16 msg = Convert.ToInt16(t % Convert.ToDouble(n));
Console.WriteLine(Convert.ToString(msg));
Note the line Convert.ToInt16(t % Convert.ToDouble(n));
where I have removed the second power function and used the result of your variable t
as your just getting the same value twice when it isn't needed.