VS 2008 Formatting A TimeSpan?
Jul 7, 2010A TimeSpan by default shows hours, minutes & seconds when converted to a string. How do I show only hours & minutes? I tried ts.ToString("hh:mm") but that doesn't work.
View 7 RepliesA TimeSpan by default shows hours, minutes & seconds when converted to a string. How do I show only hours & minutes? I tried ts.ToString("hh:mm") but that doesn't work.
View 7 RepliesI'm doing some math with the Timespans in .Net, and occasionally the sum results in a negative Timespan. When I display the result I am having trouble formatting it to include the negative indicator.
Dim ts as New Timespan(-10,0,0)
ts.ToString()
This will display "-10:00:00", which is good but I don't want to show the seconds so tried this.
ts.ToString("hh:mm")
This returns "10:00" and has dropped the "-" from the front which is the crux of the issue. My current solution is this:
If(ts < TimeSpan.Zero, "-", "") & ts.ToString("hh:mm")
but I was hoping to accomplish the same by using only the format string.
I'm working on a timekeeping application in Visual Basic 2008 and am having trouble formatting a timespan for display. Here's how I want to the information:If a positive number my Label will be: lblTimespan.txt will show as "12 Hours And 15 Minutes" This works fine.If its a negative number I want to display it as "(12 Hours And 15 Minutes)'[ in red. The problem is that I can't get rid of the minus sign. [code] Thr Replace doesn't seem to want to replace the "-", can anyone suggest what to do?
View 2 RepliesThese two TimeSpan are stored in the Database with 24hr format. No date, only TimeSpan.
Dim r As TimeSpan
Dim tsStart As TimeSpan
Dim tsEnd As TimeSpan
[Code]...
Is there any TimeSpan method to get this right?
I have a requirement that regardless of the start and dates that I need to loop through that timespan and calculate figures at the month level. I cannot seem to figure it out, and maybe it is not possible, but I would like to do something like:
FOREACH Month As TimeSpan in ContractRange.Months
Do Calculations (Month.Start, Month.End)
NEXT
Is this possible or do I need to calculate the number of months, and just iterate through the amount of months and calculate the start/end of that month based on my index?
I need to get the deff. of 2 times, Its not working for me. Here's my code
[Code]...
I need to convert a string such as "01h45m" into a TimeSpan. I know I can split the string apart to get the numbers, just looking for something more elegant...
View 2 Replies[code]what I have done (with some help) is find a timespan. the timespan (between when an employee logged in-out) is, for example, 1:15 (1 hour, 15 mins).the pay rate is 6.00 (representing $6.00)I can't get the program to multiply the timespan by the payrate..Error: 'Conversion from string "02:00:00" to type 'Double' is not valid.'
View 5 RepliesI have some VB .NET software that interfaces to a load of old (but sound) COM objects. The VB provides a GUI for the COM objects, part of which consists of setting various options on the COM objects - several of which relate to string formatting.I have a simple pair of VB .NET functions that convert basic %f, %d, %g formats to/from .NET equivalents using a large select case covering specific common strings, but they don't cover all formats.[code]Before I start diving in and making it more versatile with some parsing, does anyone know of a class (eg VB or C# .NET) that provides a decent ready-made implementation? Or perhaps some regexp wizadry could be used?
View 2 Repliesif this is not the right area to be posting this. I couldn't find an area dedicated to discussion about IDE features.Somehow one of my .vb files is not showing the nice formatting that is default in VS2008, such as the text colors, etc. how I can get this back? I don't know what to search for, as I don't know what its actually called. On the left you see what I want, and on the right you see what I have right now.
View 4 RepliesI have a program that is calculating the cost of a certain number of plane tickets, the validation and basic calculations are fine the only problem i've got this: There is a discount text box field called "txtDiscount" where IF a user enters a number it will discount this as a percentage off the total cost of all the tickets, but I cannot get it to work [Code]
View 2 Replieshave a really annoying VB 2008 problem and I'm hoping someone knows how to solve this. I implement the following code:
Code:
DispArrDate = MonthArr & "/" & DayArr & "/" & YearArr
DisplayArrDate.Text = DispArrDate.ToLongDateString
So basically, I'm getting date information from the user and trying to convert it into a date format, and show it to the user in a text box which is obviously named "DisplayArrDate", and "DispArrDate" is a date variable and "MonthArr" & "DayArr" & "YearArr" are strings which are always numbers because they are selected from a drop down combo box.
Now, the code works perfectly on my computer and some others, but for some unknown reason, on some computers, even if they have the same local date settings, it gives me the error: "Conversion from string "4/13/2009" to type 'Date' is not valid.", that's just one example, where "13" is obviously the day. I use the month/day/year format because, in the toturial I'm reading, it tells me, that no matter my local date settings, when using VB 2008, the month/day/year format should always be used and it will display a date in the local format automatically. It seems that on some computers, this isn't the case, and the month/day format is creating errors.
formating a date here
Dim dt As DateTime
dt = dsTitles.Tables(0).Rows(0).Item("servicedate")
lbldate.Text = Format(dt, "dd/mm/yy HH:MM")
The original date is - 19/08/2008 00:00:00
the date that variable dt gets is - #8/19/2008#
the final result is - 19/00/08 00:08
Good day to all of you again, I've been looking into this problem for several hours now and I can't find what is wrong with my piece of code
[Code]...
I have this string "0.9874" and I would like to use vb code to change it to "0.9.8.74" so that it looks like a proper version number.How do I do this? String.Format("{???}",MyString) or perhaps:
View 8 RepliesI want to make an application that allows you to format a drive.My application consists of a combo box (so user can select drive) and a format button to format the selected drive.
I would like to know is this possible and if so how?
I need to make sure that a certain textbox only allows dates to be entered under a certain format EG: DD/MM/YYYY
View 8 RepliesI'm a bit rusty when it comes to formatting the old xml's lol i can write them fine, i have this so far:[code]
View 3 RepliesExample:
Format(781234.57,) 781235
Format(781234.57) 781234.6
Format(781234.576) 781234.58
[code]......
I have two labels, one that will show the total gallons used in a journey and one that will show the total litres, both of these labels refer to their own Integer variables. How do I get the results to be shown only to 2 decimal places? This code below seems to work with Gallons but not with Litres?
[Code]...
PROJECT TYPE: Windows Forms Application
LANGUAGE: Visual Basic
.NET VERSION: 3.5
[code]....
I am attempting to display time in a label on my MainForm. The label should display a stopwatch control's elapsed time in hh:mm:ss format. My code is displaying "00:00:00". I have defined the hh, mm and ss as variables but I can't seem to figure out how to use them effectively.
vb
Public Sub RefreshTimeElapsed()
' Refreshes time elapsed display.
Dim hh As String = Me.MyStopWatch.Elapsed.TotalHours.ToString
[code]....
i am trying to display a line of smiley faces ☻ and change the colour of each face, i cant use a find method as there are 10 of these smilies so i thought about using a loop and selecting only the last one entered and changing its colour. here is a simplified version of my
VB.Net
For a = 0 to 9
RichTextBox1.Text += "☻" ' add the smiley
[code]....
This when i ran it changes the first nine to the first colour in the array and correctly does the colour of the last smiley? could i for instance format the character first then add it formatted?
So i wrote a script which does a few things and richtextbox2 is updated as follows:
a = 27,130,000,000
b = 2,930,000,000
c = 4,290,000,000
Problem is, when i copy the contents of richtextbox2 to the clipboard using "clipboard.settext(richtextbox2.text)" and then open up note page, and paste the clipboard contents, it is wrapped wrongly and i get the following in note pad:"a = 27,130,000,000 b = 2,930,000,000 c = 4,290,000,000"
I am using "system.envoronment.newline" in my code to start a new line.
I have a text box that displays a phone number. The data is coming from a database.Right now it just displays as "xxxxxxxxx". I'd like to display it as "xxx-xxx-xxxx" or even "(xxx) xxx-xxxx"Here's the code that I'm currently using to display the phone number - PhoneTextBox.DataBindings.Add("text", aBindingSource, "Phone")What can I add to this line to get some formatting?
View 2 RepliesI'm using Visual Basic to assign a dynamic dataset to a gridview control. The VB calls a stored procedure on SQL Server which always returns the last 28 days of info and displays it in the gridview with the column headings as the date.
[Code]...
I am currently trying to save a piece of data extracted from a piece of hardware in my office and save it as a text file. The problem now is, the text file saves the data like this:
[code].....
There are 3 buttons and 5 textboxes in my program. ignore the "plot" button as that is a machine specific code, as well as any weird lines like
Dim mgr As Ivi.Visa.Interop.ResourceManager
as these were provided by my machine vendor. I only need help with the data formatting.I am trying to program the "Agilent 8757D Scalar Network Analyzer.
I have a DGV and a TextBox into my form. The TextBox displays the "DGV.rows.count" for example as "3" but i want to show me "00003". How can i format this textbox to display data like "000XX"?
View 3 RepliesWorking on a class project where one heading in a lisbox has to be indented while the subsequent information has to be right-justified. Not sure how this is done.Have tried writing code like:
'To list cost of parts in listbox
''Formatted so value is in U.S. currency
lstTotal.Items.Add("Parts" & ControlChars.Tab & ControlChars.Tab & ControlChars.Tab & parts.ToString("C"))
But using ControlChars.Tab over and over again doesn't seem very efficient. The spacing in the listbox looks uneven and the code looks more cumbersome--less easy to read.
I have a cell in a grid view that I want to do custom formatting on. I figured out out to format the cell I'm checking but I want to format another cell called URL. The code below formats the cell "PingStatus", but how do I format another cell in the same row. I want to format a cell called URL .
Private Sub DataGrid_CurrentStatus_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGrid_CurrentStatus.CellFormatting
[code].....
I have some questions formating my datagrid and its columns but unfortunately unsuccessfully. How to change the alignment of a DataGridViewTextBoxColumn? I could only set the alignment of the whole datagrid. I tried to do this by code but it didn't do anything:
datagridOnlineStores.Columns("osowner").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
I tried defaultcellstyle but it doesn't do anything then is there any way I could change the color of the border of the whole datagrid because it's black I don't like it.