So my Question is that how do I make it so a label in visual basic change every 5 seconds but I want it to loop?
My Version of visual basic is - Visual Studio 2013
Thanks - Zacimac
Try this
startVal=1
endVal = 5
For var = startVal To endVal
lblLabel.Text = "Text " + var
await Task.Delay(2000)//Await five second
lblLabel.Refresh()
next var
Related
I tried different method to develop date picker in reactJS. I done with "react-datepicker" package and it return "Wed May 15 2019 12:54:33 GMT+0100" as a result but I need 12/12/2000 format
try to format it as you want
const pickerDate = new Date('Wed May 15 2019 12:54:33 GMT+0100')
const day = pickerDate.getDay() < 10 ? '0' + pickerDate.getDay() : pickerDate.getDay()
const month = pickerDate.getMonth() + 1 < 10 ? '0' + (pickerDate.getMonth() + 1) : pickerDate.getMonth() + 1
const year = pickerDate.getFullYear()
const formatedDate = `${day}/${month}/${year}`
you can also use third part libraries like moment
I have a date and time format:
Interval Start Time
1/13/16 1:30:00
1/15/16 10:30:00
Desired Result
Interval Start Time
13/01/2016 13:30:00 (24 Hr)
15/01/2016 10:30:00
The Interval Time is between 08:00 to 17:30.
I would like it to be: 13/01/2016 13:30 and 15/01/2016 10:30:00 and I devised this In SSIS derived Column:
(DT_DATE)(SUBSTRING([Interval Start Time],3,2) + "-" +
SUBSTRING([Interval Start Time],1,1) + "-" +
SUBSTRING([Interval Start Time],6,2) + " " +
SUBSTRING([Interval Start Time],9,1) == 1 ? "13" :
SUBSTRING([Interval Start Time],9,1) == 2 ? "14" :
SUBSTRING([Interval Start Time],9,1) == 3 ? "15" :
SUBSTRING([Interval Start Time],9,1) == 4 ? "16" :
SUBSTRING([Interval Start Time],9,1) == 5 ? "17" :
"[Interval Start Time]" )
+ ":" + SUBSTRING([Interval Start Time],11,2))
The error I get in SSIS is:
...The expression might contain an invalid token, an incomplete token, or an invalid element...
and I am not sure if the formula is correct in what I want it to do either. Any help would be much appreciated.
Before present a possible solution here, I want you be aware about some errors in your approach. Using expressions for this requeriment is very complex and hard to maintain, besides what happen when your Interval Start Time column have dates from October (10) to December (12) months, your string lenght will change and your hardcoded solution via SUBSTRING calls will return absurd data and produce error while package is running.
SOLUTION: Use Script component.
After creating your source, add a Script Component and link the source to it.
Configure the Script component to include Interval Start Time column by selecting it in Input Columns tab.
Add an output column, name it as you want and choose database timestamp (DT_DBTIMESTAMP).
Go to Script tab, and press the Edit Script... button.
Use the below code to overwrite the Input0_ProcessInputRow function.
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
/*
* Add your code here
*/
var str_timestamp = Row.IntervalStartTime.ToString();
string[] arr = str_timestamp.Trim().Split(' ');
string[] date = arr[0].Split('/');
string[] time = arr[1].Split(':');
string formatedDate = "20" + date[2] + "-" + date[0].PadLeft(2, '0') + "-" + date[1].PadLeft(2, '0');
int hour = Convert.ToInt32(time[0]);
int hour_24 = hour < 8 ? hour + 12 : hour;
formatedDate += " " + hour_24 + ":" + time[1] + ":" + time[2];
Row.MyColumn = Convert.ToDateTime(formatedDate);
}
In Row.MyColumn, replace MyColumn by the given name of your output column.
Save changes in Visual Studio and close the editor.
Now you can add a destination after the Script component and you will see the formatted IntervalStartTime as you need.
Let me know if this helps.
In windows form application, C# using Visual Studio 2012
My mask is 0.00 but when I enter 3.00 it consider just 3 not 3.00
and also when enter 3.30 it consider 3.3
but if I enter 3.01 then this value being considered.
problem is I want that it consider last zero's also.
in form designer code:
this.maskedTextBox1.Location = new System.Drawing.Point(402, 121);
this.maskedTextBox1.Mask = "0.00";
this.maskedTextBox1.Name = "maskedTextBox1";
this.maskedTextBox1.PromptChar = '-';
this.maskedTextBox1.Size = new System.Drawing.Size(31, 22);
this.maskedTextBox1.TabIndex = 23;
this.maskedTextBox1.ValidatingType = typeof(System.DateTime);
this.maskedTextBox1.MaskInputRejected += new
System.Windows.Forms.MaskInputRejectedEventHandler(this.maskedTextBox1_MaskInputRejected);
The Mask property applies to the format displayed in the Maskedit and to the characters that can be typed. It doesn't automatically format the Text for you.
If you want to display a string with the format required you need to convert the user typed text to a valid decimal and then use composite formatting to prepare a string that display the double as you wish
double d = Convert.ToDouble(maskedTextBox1.Text)
Console.WriteLine(string.Format("{0:N2}", d));
I'm trying to get Dynamic Arrays from my ActiveX component trough Visual FoxPro 9, but with no luck. (Edited and Working example)
LOCAL objMain, objAdapt
#define CrLf CHR(13) + CHR(10)
stMsg = ""
objMain = CREATEOBJECT('nnetsdk.oMain')
objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")
objAdapt = CREATEOBJECT('nnetsdk.oNetworkAdapter')
objAdapt.GetNetworkAdapters && Collects Network Adapter information
vrAdapters = objAdapt.cName && cName holds collected Network Adapter names
FOR EACH vrAdapter IN vrAdapters
stMsg = stMsg + vrAdapter + CrLf
ENDFOR
MESSAGEBOX(stMsg,64,"List Network Adapters")
RELEASE objAdapt
RELEASE objMain
Can someone explain me what is wrong with this code?
I don't know what your "nnetcom.oMain" ActiveX control is, but you can get directly from VFP via
lcComputerName = "."
loWMIService = GETOBJECT("winmgmts:\\" + lcComputerName + "\root\cimv2")
loItems = loWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
FOR EACH loItem IN loItems
lcMACAddress = loItem.MACAddress
IF !ISNULL(lcMACAddress)
*/ then, you can look at the object properties, such as
lcDescription = loItem.Description
lcMacAddress = loItem.MACAddress
lcNetConnectionID = NVL( loItem.NetConnectionID, "" )
ENDIF
ENDFOR
the For Each loop cycles through class instances of the [Win32_NetworkAdapter] class structure. You can get almost anything you want from that list.
1
Hi all i've got a complex SSIS package, however i'm hitting my head against a brick wall with a particular part. I've got a maintenance part that will delete files that are older than 3 months old (from today's date). The files all have the date in the filename, for example AA-CDR-20110606030000-2-001A648E6F74-026874.xml
So i've written a task that will loop over all the files in a particular folder using a Foreach loop, then i have a script that will load in the filename using a variable set using the foreach loop. Then delete the file using the script below. This works fine when running in debug mode. However when trying to execute this on the server i get a failure with a "System.FormatException: String was not recognized as a valid DateTime.". I really dont understand why, any ideas?
DateTime deleteDate = DateTime.Today.AddMonths(-3);
String file = Dts.Variables["FileName"].Value.ToString();
String fileDateString = file.Substring(42, 8);
String fileDateYear = fileDateString.Substring(0, 4);
String fileDateMonth = fileDateString.Substring(4, 2);
String fileDateDay = fileDateString.Substring(6, 2);
DateTime fileDateTime = Convert.ToDateTime(fileDateDay + "-" + fileDateMonth + "-" + fileDateYear);
if (fileDateTime < deleteDate)
{
System.IO.File.Delete(file);
}
It seems that there is a file on the production server that does not follow the pattern and the date cannot be extracted from its name.
Try to use something like this:
try
{
DateTime fileDateTime = Convert.ToDateTime(fileDateDay + "-" + fileDateMonth + "-" + fileDateYear);
if (fileDateTime < deleteDate)
{
System.IO.File.Delete(file);
}
}
catch (System.FormatException)
{
// log the Dts.Variables["FileName"] value here to see why it could not be parsed
}