|
"Learn Flash".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What is it you want to create?
|
|
|
|
|
It's not a Windows app. It's all Flash.
/ravi
|
|
|
|
|
Hi im not sure if I can ask for help here, my appolagise if not I will remove if required to.
I am stuck however with a hangman style game I am building, Simply a word pulls from file at random and the output to the user is '*' symbols instead of the letters, the user can select to guess a letter from the keyboard etc... The program does cross ref the guess with the actual word and if the user guesses correctly it will replace the '*' with the correct letter, the issue is it will only do one loop so wont allow for continuation until the word is complete. I would appreciate any help with this so that the user keeps going until the word is completed. Many Thanks. Here is the code:
private void chckGss_Func(string wordToGuess)
{
StringBuilder showUser = new StringBuilder(fileWord.Length);
for (int i = 0; i < fileWord.Length; i++)
showUser.Append('*');
List<char> goodGuess = new List<char>();
List<char> badGuess = new List<char>();
int lives = 5;
bool win = false;
int charReveal = 0;
string inpt;
char guess;
while (!win && lives > 0)
{
inpt = tmpLttr.ToUpper();
guess = inpt[0];
if (goodGuess.Contains(guess))
{
btnCorrect.Visible = true;
lblCorrect.Visible = true;
continue;
}
else if (badGuess.Contains(guess))
{
btnWrong.Visible = true;
lblWrong.Visible = true;
continue;
}
if (wrd2GuessUpper.Contains(guess))
{
goodGuess.Add(guess);
for (int i = 0; i < fileWord.Length; i++)
{
if (wrd2GuessUpper[i] == guess)
{
showUser[i] = fileWord[i];
charReveal++;
}
}
if (charReveal == fileWord.Length)
win = true;
}
else
{
badGuess.Add(guess);
lives--;
return;
}
txtWrdToGuess.AppendText(showUser.ToString());
}
if (win)
MessageBox.Show("You win!");
else
MessageBox.Show("You lose, the word was " + fileWord);
}
|
|
|
|
|
I think the problem is that return statement near the bottom. Replace it with a continue statement and I think it will work.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Iv already tried that, i heard last night that apparently it may well be the while statement thats causing the issue so ill have a look at that today
|
|
|
|
|
Hello,
I have a DLL that is a linked reference in my C# project. I would like to test for its existance before opening my form using something like "File.Exists()". I cannot find a place in my program to put the file test before an exception is thrown when the DLL is missing.
The following code works if the DLL resides in the directory with the EXE. If the DLL is missing an exception is thrown.
static void Main()
{
string message_out = (File.Exists(USBClassLibrary.dll) ? "DLL found." : "DLL missing");
MessageBox.Show(message_out);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
I thought that referenced DLLs were loaded on demand so I am puzzled by this error.
Thanks,
SMW
|
|
|
|
|
Stephen Wickland wrote: I thought that referenced DLLs were loaded on demand so I am puzzled by this
error. They are, but it's the environment that does it. If you add a reference to the project, then it has to be there in order to run.
Two alternatives; test from another program, and launch either an exe with or one without a reference. The other alternative is to load the assembly yourself, and instantiate the types yourself. Then you'll also have a statement in your code that loads the DLL, and then you can skip loading.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks BP,
Not the answer I was hoping for but I now understand the situation and can move ahead.
SMW
|
|
|
|
|
You can probably have another program to an existence test before running the application.
|
|
|
|
|
Hi All,
I develop a windows form to read excel file using oledbconnection, my problem is when any column header in excel file contains dot (.), such as customer.Name I get the following error:
" Invalid bracketing of [Customer.Name] ".
Please help me to solve this problem and how to remove . from the columns.
Thanks for your effort
|
|
|
|
|
Show us the relevant code snippet!
|
|
|
|
|
HI,
This is the code:
Hi,
this is the code:
string conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=filepath;Extended Properties=Excel 12.0 XML;HDR=Yes;IMEX=1;MaxScanRows=0;";
OleDbConnection con=new OleDbConnection(conString);
con.open();
OleDbCommand command = new OleDbCommand("select * from [sheet1$]", con);
OleDbDataReader reader = command.ExecuteReader();
DataTable dt=new DataTable();
dt.load(reader);
con.close();
Thanks
|
|
|
|
|
I just tried that and the dot got changed to a hash (#) character.
|
|
|
|
|
Hi ,
this is my code, please let me know if there is any problem in it.
string conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=filepath;Extended Properties=Excel 12.0 XML;HDR=Yes;IMEX=1;MaxScanRows=0;";
OleDbConnection con=new OleDbConnection(conString);
con.open();
OleDbCommand command = new OleDbCommand("select * from [sheet1$]", con);
OleDbDataReader reader = command.ExecuteReader();
DataTable dt=new DataTable();
dt.load(reader);
con.close();
|
|
|
|
|
Sorry, it still works for me, there must be some other problem in your code.
|
|
|
|
|
The code you have given us looks ok - so it's time to look at your data.
What does the row giving the problem look like?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I think it's not the data, but the columns name; as soon as it gets mapped, it'll recognize the illegal name. It'll be valid in Excel, but not in a real database.
Simple solution; rename the column, remove the dot.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Could be - but I'd expect OleDb to cope better than that.
Be good to see the actual data so we can duplicate the fault.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
HI, I am working on a project in which I have to make calls to mobile phone through USB dongle(Netsetter) I am using Huawei E1550 modem,I have done the calling part using AT commands but the modem is not supporting for voice,means I am not able to send the voice, please guide me which USB modem I should use that supports voice please help me in this matter, my modem gives error to AT+FCLASS=8 which is the voice enable.
|
|
|
|
|
Following words in google seem to return results that suggest which modems do it.
usb modem voice
|
|
|
|
|
I have a winform and a picturebox.
In the picturebox I´m running a XNA-game.
In the winform I have:
Game1 game = new Game1();
public Game1 Game
{
get
{
return game;
}
set
{
game = value;
}
}
In the XNA-form I try
public Form1 form = new Form1();
public Form1 Form
{
get
{
return form;
}
set
{
form = value;
}
}
I can via methods send info to the game using:
game.StartBoat();
where StartBoat is a method in my XNA-game.
I would like to send info to the winform also.
But I get a stackoverflow exception indicating an infinite loop. How should I do it if possible?
|
|
|
|
|
That code does not make much sense, in both cases the get and set would seem redundant.
|
|
|
|
|
Richard MacCutchan wrote: That code does not make much sense, in both cases the get and set would seem redundant.
Well, I´m not a superexpert in C# and certainly not XNA so I have got a lot of help via forums.
|
|
|
|
|
If one of those is responsible for creating the other, don't new up the original one in the new one. So, if Form1 creates Game1, don't do new Form1() in Game1. That will clear your stack overflow.
Now, as to the second part of your problem. There are a few things you could do to get around this. The first method is to pass a reference to Form1 into the1 Game constructor (or explicitly set it at some point before you try to use Game).
public class Game1 : Game
{
private Form1 form;
public Game1(Form1 form)
{
this.form = form;
}
}
public class Form1 : Form
{
private Game1 game;
public Form1()
{
game = new Game1(this);
}
} The other way to do this, and the way I tend to prefer, is to use events in Game1 to signal that Form1 should do something. By using events, you decouple Game1 from having to know anything at all about Form1 - which means you could swap it into other projects far easier. Basically, after you instantiate Game1 in Form1, you can subscribe to the events that you're interested in and use those as appropriate.
|
|
|
|