|
I need in a console application to have user input an integer in military time that be converted some how to 13:00 or 13:30 instead of 1330 the pure number.
So that I can then take 1330 and have the user input an end time like 1430 and increase it by 25 percent to come out with 1445 or 2:45. So your increases the total time from 1 hour to 1 hour and 15 minutes.
The input will always be HHMM in military time
Simple Function is needed nothing advanced
|
|
|
|
|
So what have you written?
You seem to have the wrong idea what this forum is for, we help budding developers improve their skills and learn, we do not supply solutions, that is your job.
There are other sites that will supply the solution for a minimal payment, you may want to try there!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I expect that one of the Parse methods of System.DateTime is all you need -- no integer is necessary.
And why does this sound like homework?
"HHMM in military ISO 8601[^] time"
FTFY
modified 4-Jun-12 21:51pm.
|
|
|
|
|
Your darn right its homework. Seeing as original thought doesn't exist and I have spent the better part of the day wrestling with this. I reached out to the community for insight.
|
|
|
|
|
If that's the better part I don't want to see the worse part. 
|
|
|
|
|
I think the following points may be helpful.
Use DateTime.ParseExact to parse the time
DateTime startTime = DateTime.ParseExact("1330","HHmm",
System.Globalization.CultureInfo.InstalledUICulture);
similarly parse the end time.
Now find the duration between end time and start time using the Subtract method of DateTime object which returns a TimeSpan object.
Then get the total minutes using the TotalMinutes method of TimeSpan object.
Use the AddMinutes method of DateTime to add minutes to the end time
Then get the string representation of modified end time using
string endTimeString = endTime.ToString("HHmm",
System.Globalization.CultureInfo.InvariantCulture);
modified 4-Jun-12 23:17pm.
|
|
|
|
|
Hello CodeProject
I've been using this textbox custom control: AlphaBlendTextBox - A transparent/translucent textbox for .NET[^]
and like others, I am having problems using Events When I tried using the Hover event, nothing would happen when I Hovered over the Custom Textbox.
I know usually it would be better to ask the creator of it, but he's not responding to any questions sadly. This custom control is very important to me & would love it if someone could kindly help me
I would be very thankful, thanks
|
|
|
|
|
I don't know how that works, but from a quick skim, I'd look at where the events get forwarded from the PictureBox to the actual control.
Also the whole thing seems like a dirty hack and you might be better off doing a custom control and writing the text editing logic separately.
|
|
|
|
|
Hi all,
My application lets a user select a True Type font from the FontFamily.Families enumeration:
foreach (FontFamily ff in FontFamily.Families)
{
if(ff.IsStyleAvailable(FontStyle.Regular))
fontCombo.Items.Add(ff.Name);
}
This doesn't work for Open Type fonts, e.g. I just installed Costura Light, and it's now available in MS Word, but invisible to my enumeration above.
Googling doesn't reveal any solution to this; all the sites just assume the font is there after you install it.
What do I have to do to make Open-Type fonts available? Thanks!
=========================
EDIT -- THERE'S NO SIMPLE WAY TO DO THIS: GDI+ ONLY SUPPORTS TRUE TYPE. THERE'S A CONVOLUTED WAY TO USE GDI FOR OPEN-TYPE FONTS FROM MANAGED C++ DESCRIBED HERE: http://www.codeguru.com/cpp/g-m/gdi/fonthandlinganddetection/article.php/c10621/Make-GDI-Less-Finicky-About-Fonts.htm[^]
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
modified 4-Jun-12 16:09pm.
|
|
|
|
|
Can someone please provide a sample code which explains all features of OOPS in C#.
Thanks in advance.
Kris
kriskan
|
|
|
|
|
Can someone please explain what the S stands for in OOPS?
could it be OOPSS for object-oriented programming self study?
|
|
|
|
|
|
Would you liked to be tagged "Abusive/Troll"??
Luc is one of the most respected people on this site and your first post is to tell him to "shutup". Nice job introducing yourself.
|
|
|
|
|
There are many examples of C# oops in the Hall of Shame.
|
|
|
|
|
You should ask google....
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I think you should pick up a book on object oriented programming and go through it.
A case study will be good for a start but will not be enough to cover more detailed topics like operator overloading etc.
|
|
|
|
|
|
Someone (I guess OP) did not like your offer of help; I have adjusted the score.
|
|
|
|
|
OOPS! The uni-voter did it again...
Countered.
|
|
|
|
|
Just for the record, this is not a question that can be answered in a programming forum. Yes, someone could give you some sample code, but while it might give examples of all features, it would probably not explain them. And in any case, such an answer would take up far too much space. What you are asking for is the text of a book, which is beyond the capabilities of this site. Take a look at some of the links that others have provided and prepare to get down to some serious study.
|
|
|
|
|
i'm new at c#, so i convert my messenger project from vb.net to c#, but after dat the problem occurs.
i got an error saying
//The best overloaded method match for 'System.Net.Sockets.Socket.Receive(ref.System.Net.IPEndPoint)' has some invalid arguments// in this line :
data = ReceivingClient.Receive(endPoint);
i've tried to convert it to Byte but still can't work.
can someone please tell me what's wrong?
here's the full code :
public delegate void AddMessage(ref string message);
private const int Port = 33333;
private const string BroadcastAddress = "255.255.255.255";
private UdpClient ReceivingClient;
private UdpClient SendingClient;
private Thread ReceivingThread;
private bool EnableReceiver = true;
public Client()
{
InitializeComponent();
}
private void Client_Load(object sender, EventArgs e)
{
InitializeSender();
InitializeReceiver();
}
private void MessageReceived(ref string message)
{
textbox1.Text = message;
}
private void Receiver()
{
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, Port);
AddMessage messageDelegate = MessageReceived;
while ((EnableReceiver == true))
{
byte[] data = null;
data = ReceivingClient.Receive(endPoint);
string message = Encoding.ASCII.GetString(data);
Invoke(messageDelegate, message);
}
}
private void InitializeSender()
{
SendingClient = new UdpClient(BroadcastAddress, Port);
SendingClient.EnableBroadcast = true;
}
private void InitializeReceiver()
{
ReceivingClient = new UdpClient(Port);
ThreadStart start = new ThreadStart(Receiver);
ReceivingThread = new Thread(start);
ReceivingThread.IsBackground = true;
ReceivingThread.Start();
}
modify >>>>
finally i found it, like this :
data = ReceivingClient.Receive(ref(endPoint));
thank you very much. 
modified 4-Jun-12 6:25am.
|
|
|
|
|
According to the documentation[^] (which is where you should always check first), the Receive() method does not take an endpoint as a parameter.
|
|
|
|
|
The CLR classes are the same, whether you call them from a VB.NET app or a C# app. So if the C# version doesn't work for you, well, something got lost in translation. Wasn't there a ByRef in your VB.NET app?
Midnight Ahri wrote: data = ReceivingClient.Receive(ref(endPoint));
And that is too many parentheses to my taste.
|
|
|
|
|
Hi Guys,
I've made a program to read data from an SQL database and show those in dynamic comboboxes. Now I would like to save all data back to SQL database after changes was made in those comboboxes.
Any ideea how to accomplish this?
Best regards
Vidor
public void showRequill()
{
DataSet dsRequill = new DataSet();
BindingSource bsRequill = new BindingSource();
SqlDataAdapter daRequill = new SqlDataAdapter();
DataTable dtRequill = new DataTable();
int cnt = 0;
try
{
daRequill.SelectCommand = new SqlCommand("select * from RD1 where UserNumber='" + cbWorkerNr.Text + "'", CN);
daRequill.Fill(dsRequill);
daRequill.Fill(dtRequill);
bsRequill.DataSource = dsRequill.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
foreach (DataColumn column in dtRequill.Columns)
{
newLabel = new Label();
newCombo = new ComboBox();
newLabel.Text = column.ColumnName;
newLabel.AutoSize = true;
newLabel.Visible = true;
newCombo.Size = new Size(35, 21);
newCombo.Items.AddRange(new object[] { "U", "S", "E", "B", "L" });
newCombo.Name = "cbRequill_" + cnt.ToString();
newCombo.Visible = true;
newCombo.DataBindings.Clear();
newCombo.DataBindings.Add(new Binding("Text", bsRequill, column.ColumnName));
newCombo.TextChanged += new EventHandler(newCombo_TextChanged);
flpRequill.Controls.Add(newLabel);
flpRequill.Controls.Add(newCombo);
cnt++;
}
}
|
|
|
|
|
Hi,
what i understand is, you have some list of items to display and then after update that items it should be back to the database. correct ?
so what i suggest is, at the time of updating data. Do not use update query. instead remove all those records and insert it again(using single transaction). because you do not have idea about which data is modified.
Or the other solution is, you need to maintain index of the data you get from database. and then match the string value and update only if it modified. but this way leads to so many questions.
let me know above idea works for you,
thanks
-Amit.
|
|
|
|