|
Right click the cell and select Format. Then select "Text" within the popup-dialog.
|
|
|
|
|
Yea, I know how to do it manually. But I want to do it in runtime. Reason is all the time formatting it manually not make sense.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
|
I'm using OLEDB connection to read the excel file. What happen is only one formatting is binding, text or numeric. Actually most number of occurrence type is binding.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I am creating a (first person shooter)-ish video game for my comp. sci. class and I can't get my character to strafe properly. I can have it move forwards and backwards but not side to side (at least not relative the the object, only the world). here is the code to move the object forward.
if (keyboardState.IsKeyDown(Keys.W))
{
Vector3 pos = GetMissileMuzzlePosition();
missileLauncherHead.velocity = missileLauncherHead.position - new Vector3(pos.X, 0, pos.Z);
missileLauncherBase.velocity = new Vector3(0.0f, 0.0f, 0.0f);
missileLauncherHead.position -= missileLauncherHead.velocity;
missileLauncherBase.position -= missileLauncherBase.velocity;
}
and here's the code to make the object (its a cannon at this point) move to the left.
if (keyboardState.IsKeyDown(Keys.A))
{
Vector3 pos = GetMissileMuzzlePosition();
Vector3 refer = new Vector3(missileLauncherHead.position.X + 5, missileLauncherHead.position.Y,missileLauncherHead.position.Z);
missileLauncherHead.velocity = refer - missileLauncherHead.position;
missileLauncherBase.velocity = new Vector3(5.0f, 0.0f, 0.0f);
missileLauncherHead.position -= missileLauncherHead.velocity;
missileLauncherBase.position -= missileLauncherBase.velocity;
}
I a complete noob when it comes to vectors. I literally just learned how to do this in my calculus/vectors couse a few weeks back.
|
|
|
|
|
I would expect that if changing the X value moves you forward, then changing the Y value would move you side to side. You're reversing the vector. Remove the component that moves you forward and replace a 0 with the amount to move left or right.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I tried, it didn't work. the object either got stuck in place or shot up in the y direction.
|
|
|
|
|
Hi all,
I have a folder contains a lot of files, i need to browse to that folder using FolderBrowserDialog and read all the files (at once) and save/upload its content into an sql database table. please, will you help me with the approach/code of doing that.
Thanks.
|
|
|
|
|
Try this.....
FolderBrowserDialog fbd = new FolderBrowserDialog();
DialogResult result = fbd.ShowDialog();
if (result == DialogResult.OK)
{
DirectoryInfo di = new DirectoryInfo(fbd.SelectedPath);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(fbd.SelectedPath);
foreach (string file in files)
{
}
}
}
Have a Happy Coding.....
|
|
|
|
|
Thanks a lot for your help King Julien.
after looping through the files, I read each line in a file and save everything to the database. I have a date field that is sometimes empty I've initialized it to
DateTime DateOpened = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
Now, when I'm reading the date
if (line.Contains("Date Opened :"))
{
line = reader.ReadLine();
DateOpened = Convert.ToDateTime(line);
line = reader.ReadLine();
}
I get a FormatException error: String was not recognized as a valid DateTime. Please advice where I did wrong.
Thanks.
|
|
|
|
|
Hi NOPO,
As i could see, you are passing the entire line to the ToDateTime() function.
If the line have a string similar to a date time, the function converts it to the correct DateTime.
I am not sure what string you have in the line. If it contains variety of strings, parse it first and pass it to the Conversion function.
As from the microsoft documentation,some of the valid strings that could be converted are
dateString = "05/01/1996";
ConvertToDateTime(dateString);
dateString = "Tue Apr 28, 2009";
ConvertToDateTime(dateString);
dateString = "Wed Apr 28, 2009";
ConvertToDateTime(dateString);
dateString = "06 July 2008 7:32:47 AM";
ConvertToDateTime(dateString);
dateString = "17:32:47.003";
ConvertToDateTime(dateString);
dateString = "Sat, 10 May 2008 14:32:17 GMT";
ConvertToDateTime(dateString);
dateString = "2009-05-01T07:54:59.9843750-04:00";
ConvertToDateTime(dateString);
Wish you a good luck....
Have a Happy Coding.....
|
|
|
|
|
line variable contains 19990723 as a date, how then do I convert such date?
|
|
|
|
|
19990723??????
Are you sure thats a date??????
Is it manually entered in the file or a system generated value????
Have a Happy Coding.....
|
|
|
|
|
If it's YearMonthDay, then use DateTime.ParseExact and look into format strings - they're used for the parsing mechanism
|
|
|
|
|
|
Ok I have a situation where I have my main form that opens at the beginning.
Once that form opens there is a button Add Time and a label ttlTime which shows the total amount of time stored.
Once Add Time is clicked a form opens. In that form there are buttons that have letters on them.
The user can click on any button and it then closes that form and opens the actual AddTime form.
In this AddTime form there are comboboxes that allow you to select certain things. Once the form is filled out.
You click on Submit and it posts data to an xml file which stores the hours and then closes the AddTime form and shows the Main form again. I would like to be able to somehow call an event on closing the AddTime form or the showing of the Main form to update the ttlTime label so that they can see the updated time without having to click on a refresh button or something similar. If anyone knows of a way to accomplish this. It would be a great help. I have tried doing some get/set and I cant seem to figure out how to get the label updated.
Thanks for the help.
|
|
|
|
|
use Form.Closing or Form.Closed event to trigger a delegate in which you can do all the required work (updating ttlTime etc.....)
Have a Happy Coding.....
|
|
|
|
|
The issue is I can actually do what i want by.
opening the main form.
Then open AddTime form directly and it will update the label using a custom event.
But the problem is I cant seem to figure out how to open the filter window first then when the letter is selected it opens the AddTime form then when i close the AddTime window have it update the label ttlTime then.
In Basic words I want to be able to.
1. open main form
2. open filter form off of main form
3. open addtime form off of filter form
4. when I click on the close button event I would like to update the label.
pretty much it. I am just not sure code wise how to accomplish this.
Thanks for your quick reply btw.
|
|
|
|
|
|
Thanks the answer helped but I solved it by doing this.
Thanks to a post here http://forum.codecall.net/c-programming/515-c-calling-parent-functions-child-form.html#post2214[^]
Void's post...
-Example-
MainForm Code:
namespace CallParentFuncFromChildChild
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Child1 child1 = new Child1(this);
child1.Show();
}
public void msgme()
{
MessageBox.Show("Parent Function Called");
}
}
}
Child1 Code:
namespace CallParentFuncFromChildChild
{
public partial class Child1 : Form
{
private MainForm m_mainForm;
public Child1(MainForm mainForm)
{
InitializeComponent();
m_mainForm = mainForm;
}
private void button1_Click(object sender, EventArgs e)
{
SubChild1 subChild1 = new SubChild1(m_mainForm);
subChild1.Show();
this.Close();
}
}
}
SubChild1 Code:
namespace CallParentFuncFromChildChild
{
public partial class SubChild1 : Form
{
private MainForm m_mainForm;
public SubChild1(MainForm mainForm)
{
InitializeComponent();
m_mainForm = mainForm;
}
private void button1_Click(object sender, EventArgs e)
{
m_mainForm.msgme();
this.Close();
}
}
}
Thanks again for the help and I hope this helps someone. :]
|
|
|
|
|
Hi programmers,
I'm working a software called VeriLook in C#. I had some problems saving the image to a file after capturing the image.
namespace prac_8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
CameraMan cameraMan = new CameraMan(null);
Console.WriteLine("Found cameras (id, default resolution, automatic settings):");
foreach (Camera camera in cameraMan.Cameras)
{
CameraVideoFormat videoFormat = camera.VideoFormat;
Console.Write("\t{0}, {1}x{2}x{3:f2}, {4}",
camera.ID, videoFormat.FrameWidth, videoFormat.FrameHeight,
videoFormat.FrameRate, camera.AutomaticSettings);
camera.StartCapturing();
NImage image = camera.GetCurrentFrame();
Bitmap bm = image.ToBitmap();
videoControl.Image = new Bitmap(bm);
}
}
private void button2_Click(object sender, EventArgs e)
{
Bitmap bm = videoControl.Image;
NImage image = NImage.FromBitmap(bm);
NGrayscaleImage grayscale = (NGrayscaleImage)NImage.FromImage(NPixelFormat.Grayscale, 0, image);
NLExtractor extractor = new NLExtractor();
NleDetectionDetails details;
NleExtractionStatus extractionStatus;
NLTemplate template = extractor.Extract(grayscale, out details, out extractionStatus);
if (details.FaceAvailable && details.EyesAvailable)
{
MessageBox.Show("Found face and eyes!");
}
if (extractionStatus != NleExtractionStatus.TemplateCreated)
{
MessageBox.Show("Extraction failed!");
return;
}
NLTemplate compressed = extractor.Compress(template);
if (compressed == null)
{
Console.WriteLine("Face template compression failed!");
return;
}
BinaryWriter writer = new BinaryWriter(new FileStream(args[0], FileMode.OpenOrCreate, FileAccess.Write));
writer.Write(compressed.Save());
writer.Close();
}
}
}
Basically this is what i have
I had encountered an error with
"The name 'args' does not exist in the current context." line 81
what does it mean? and what can i do to solve it? what should i put down?
thanks!~
|
|
|
|
|
Since you don't use "args" anywhere in this code, and you don't specify which line the error occurs on, I can only assume that it's a problem with the library you're using.
|
|
|
|
|
Dave Kreskowiak wrote: you don't specify which line the error occurs on
Hi,
If you read carefully the error is on line 81 which i had specified.
|
|
|
|
|
|
Do you really expect us to count the lines?
Highlight (put in bold) or mark with comment or even repeat the line that gives the error.
|
|
|
|