Windows Phone: How to set the Value of TimeSpanPicker Programmatically? - windows-phone-8

I am trying to use TimeSpanPicker in my application. How Can I set the value to "00:00:00"? For example, I am creating an instance and setting the Value to "00:00:00" but it seems that
I should not assign a String ("00:00:00") to ts.Value.
enter code here
TimeSpanPicker ts= new TimeSpanPicker();
ts.Value="00:00:00";
Error: Cannot implicitly convert type 'string' to 'System.TimeSpan?
How can I set TimeSpanPicker's value?
Thanks,
Bahador

If you take a close look at the error you are getting, it says that it can not automatically convert a string to a TimeSpan and that the Value is expecting a TimeSpan. If you further look at your TimeSpan Object you will find that it has a Parse Method. So something like this will work for you.
TimeSpanPicker ts= new TimeSpanPicker();
ts.Value= TimeSpan.Parse("00:00:00");

Related

osisoft updating values ​with python

I want to get the data from Excel and update the values ​​of the data between certain dates in the osisoft system. But I don't know how to code AfTimeRange.
I get the error "value cannot be converted to OSIsoft.AF.Time.AFTime".
enter image description here
Good news: You've constructed your [AFTimeRange] correctly!
Notice that the error being thrown is not by the [AFTimeRange] constructor, but from something else.
The issue is that you are trying to set the 'Timestamp' attribute [OSIsoft.AF.Time.AFTime] to a value of type [OSIsoft.AF.Time.AFTimeRange], and so it's failing. A PI event has a single timestamp, not a time range.
I'm not familiar with Python, but it should work if you input the value as an AFTime object using its string constructor, assuming you're intending to use yesterday midnight as your timestamp:
val.timestamp = AFTime("y")
See the documentation on AFTime for more detail.

Mysql VB.NET: Hiding column from datagridview null exception error (column is not null)

I have a datagridview that is populated with the data I retrieved from the database (mysql)
When I try to hide the column or change the column header text, this exception was thrown:
Object reference not set to an instance of an object.
or
Index was out of range. Must be non-negative and less than the size of
the collection. Parameter name: index
with this simple code:
gridjobs.Columns(0).Visible = False
gridjobs.Columns("JOB_NO").HeaderText = "JOB NO."
I can tell you that the datagrid is not null, it was working before but suddenly this error popped up. I tried searching the net but still no luck in fixing this error. Everything is working, except this. Is there something wrong with my code?
based on google
Object reference not set to an instance of an object. exactly what it says, you are trying to use a null object as if it was a properly referenced object. ... Most of the time, when you try to assing value into object, and if the value is null, then this kind of exception occur.
This one is common sense here is your code.
gridjobs.Columns(0).Visible = False
gridjobs.Columns("JOB_NO").HeaderText = "JOB NO."
the first column is Visible = False then you assigned a header text? How can I assign a value in an Object that Invisible?
Just a wild guess.
and also why do u need to assign a header that will be visible = false also? anyway try this
gridjobs.Columns(0).Visible = False
gridjobs.Columns(0).HeaderText = "JOB NO."

Error converting value {null} to type 'System.DateTime' Json Response VB.NET

I am trying to use JsonConvert.DeserializeObject to parse a JSON response that I am getting back from a web-service. I have the XSD Schema file for the service, which I ran though the .net converter tool to make a Class. Which everything works perfectly, other than the below field. I get the error in the title. It only happens on Array's of Dates, single dates that have a null return work perfectly fine and are skipped due to turning on the NullValueHandling.Ignore setting. Does anyone know how I could use JSON.NET to skip over theses null dates in the array too? Thanks in advance!
JSON Response: "TheDatesReturned":[null,null,null,null,null,null],
Private TheDatesReturnedField() As Date
<System.Xml.Serialization.XmlElementAttribute("TheDatesReturned", DataType:="date")> _
Public Property TheDatesReturned() As Date()
Get
Return Me.TheDatesReturnedField
End Get
Set(value As Date())
Me.TheDatesReturnedField= value
End Set
End Property
NOTE: Changing it to an array of strings fixes it as well, but then they are no longer typed correctly when I actually do get a response.
EDIT:
If any anyone comes across this and is wondering how to get XSD.exe to do it for them. They can add nillable="true" to the field in the XSD file
<xsd:element maxOccurs="6" minOccurs="0" name="TheDatesReturned" type="xsd:date" nillable="true">
This will then generate the Class with this, which should take care of the issue.
Private TheDatesReturnedField() As System.Nullable(Of Date)
Possibly because DateTime is not a nullable type? Try using DateTime? as the type.

Current Field Value into a VBA String Programmatically

I need to take the current value of a field from the record displayed on an open Access form and put the text in that field into a VBA string programmatically. This seems so simple but I have not yet been to find any guidance from either an aftermarket Access 2013 text I purchased or the Internet. I have tried everything I can think of with no success whatsoever so I posted a question on stackoverflow.com and received the following suggested solution:
Dim strYourString as String
strYourString = Forms![Your Form Name].[Field Name].Value
When this is run I get:
Runtime error ‘438’
Object doesn’t support this property or method
Any help will be greatly appreciated!
Try using a bang symbol in front of the field name, instead of a period.
strYourString = Forms![Your Form Name]![Field Name].Value
^---------------------Bang symbol here
This is supported by the documentation here on MSDN. Note the implicit form:
Forms!OrderForm!NewData
where NewData is the name of a control. Or you can use an explicit reference:
Forms!OrderForm.Controls!NewData
If you want to refer to a field in the underlying recordset of the form instead, use:
Forms!MyForm.Recordset.Fields("MyFieldName")

Umbraco razor template - Get Formatted Date From Field specified in parameter

I'm trying to return a formatted date from a razor template in umbraco. I'm not sure how to get a value from a field defined in a parameter though.
Here is the code I'm playing with. The field I'm passing in is called "articleDate". I'm getting the parameter value output, however when I try to get the value of the field using the parameter name it returns nothing. If I ask for the value by the field name itself, that works. How can I create a generic macro like this?
#{var param = #Parameter.dateField;}
Field Name: #param
<br/>
Field Value: #Model.param
<br/>
Field Value: #Model.articleDate
I tried using #Model.GetDynamicMember(..) as well, but that just throws an exception.
Field Value: #Model.GetDynamicMember("articleDate");​
Error loading Razor Script getDate.cshtml
Cannot invoke a non-delegate type
Can someone point me in the right direction? I'm just trying to create a simple macro I can use to format dates across my page.
Is it possible to pass the value of my date directly into the razor macro? This is how I'm currently calling it:
<umbraco:Macro ID="Macro1" Alias="getDate" dateField="articleDate" runat="server"></umbraco:Macro>
If you call your Macro like you wrote:
<umbraco:Macro ID="Macro1" Alias="getDate" dateField="articleDate" runat="server"></umbraco:Macro>
You're actually passing the name of the field "articleDate". In the macro, you then may get the value of the Model's articleDate property by using:
Field Value: #Model.getProperty(Parameter.dateField).Value
Instead of macro's I also recommend using helpers or - for more complex scripts - RenderPage. A nice writeup can be found here:
http://joeriks.wordpress.com/2011/03/11/better-structure-for-your-razor-scripts-with-renderpage-in-umbraco/
Example:
#helper GetDate(dynamic dateField)
{
#dateField.ToString("[yourFormat]")
}
You may pass parameters to scripts rendered with RenderPage by using the Page object:
<umbraco:macro language="razor" runat="server">
#{
Page.dateField=Model.articleDate;
}
#RenderPage("~/macroscripts/getdate.cshtml")
</umbraco:macro>
getdate.cshtml:
#Page.datefield.ToString("[yourFormat]")