foreach

C# Progressbar value in foreach()

怎甘沉沦 提交于 2020-01-06 15:19:05
问题 I have this code: private void button1_Click(object sender, EventArgs e) { var max = 0; foreach (var address in textBox2.Text.Split(',')) { max = +1; } var maxp = 100 / max; foreach (var address in textBox2.Text.Split(',')) { SendMessage(address); progressBar1.Value = +maxp; } } It calculates how many emails are in the textbox, and then makes a proportion. To each email sent adds the value of progress, the problem is that when I press the button, the progressbar does not move. When all emails

C# calling all properties, for each loop

廉价感情. 提交于 2020-01-06 15:01:31
问题 I have a foreach loop and I would like to call all properties of a certain class in the foreach loops so I don't have to write it all out. The class I have created public Person() { firstname = ""; surname = ""; haircolor = ""; eyecolor = ""; weight = 0; height = 0; age = 0; } This is the code I am trying to compact Console.WriteLine("Please enter the next persons firstname");//new person user input (firstname) addperson.firstname = Console.ReadLine(); Console.WriteLine("Enter the persons

Load Array via nested foreach loops in PHP?

余生颓废 提交于 2020-01-06 14:05:58
问题 I am trying to generate an array that looks like this: Array ( [Album1] => '<img src="album1_thumb1.jpg">' [Album1] => '<img src="album1_thumb2.jpg">' [Album2] => '<img src="album2_thumb1.jpg">' [Album2] => '<img src="album2_thumb2.jpg">' ) Right now I have two nested foreach loops that look like so: $subfolders = glob($directory); foreach($subfolders as $subfolder) { $photos = glob($subfolder.'/*.[Jj][Pp][Gg]'); foreach($photos as $photo) { $thumbnail = $subfolder.'/thumbs/'.$photoname[0].'

Load Array via nested foreach loops in PHP?

不羁岁月 提交于 2020-01-06 14:00:16
问题 I am trying to generate an array that looks like this: Array ( [Album1] => '<img src="album1_thumb1.jpg">' [Album1] => '<img src="album1_thumb2.jpg">' [Album2] => '<img src="album2_thumb1.jpg">' [Album2] => '<img src="album2_thumb2.jpg">' ) Right now I have two nested foreach loops that look like so: $subfolders = glob($directory); foreach($subfolders as $subfolder) { $photos = glob($subfolder.'/*.[Jj][Pp][Gg]'); foreach($photos as $photo) { $thumbnail = $subfolder.'/thumbs/'.$photoname[0].'

Mysql wrongly update the dynamic row records [duplicate]

空扰寡人 提交于 2020-01-06 08:30:07
问题 This question already has answers here : dynamic row values wrongly updated into mysql php (4 answers) Closed 6 years ago . I trying to update my dynamic row values here. When i insert a new voucher record it could inserted the values correctly into database. When i edit the record values that time also it fetch the values from database correctly. But updation is my problem. It always update the last row values in all rows.. Previously i posted another question here related to this question

Iterate through Windows forms and close them?

五迷三道 提交于 2020-01-06 08:16:51
问题 I'm trying to use the following code to iterate over all of the currently open forms in my application and close them except for the main form as part of a clean up. Dim openForms As Windows.Forms.FormCollection = Application.OpenForms For Each frm As Windows.Forms.Form In openForms If frm.Name.ToString() <> "FrmMainNew" Then frm.Close() End If Next However, I'm getting an InvalidOperationException because when frm.Close() is executed, the entry that was in openForms is deleted, changing the

How can I ignore “XXX” titles in my data parsing script?

依然范特西╮ 提交于 2020-01-06 08:14:11
问题 I've tried and it doesn't seem to work. Any help would be greatly appreciated. CODE: foreach (glob('mov/Alene*.mov') as $filename){ $theData = file_get_contents($filename) or die("Unable to retrieve file data"); } $string = $theData; $titles = explode("\n", $string); function getInfo($string){ $Ratings = ['G', 'PG', 'PG-13', 'R', 'NR', 'XXX']; $split = preg_split("/\"(.+)\"/", $string, 0, PREG_SPLIT_DELIM_CAPTURE); if(count($split) == 3){ preg_match("/(".implode("|", $Ratings).")\s/", $split

Removing Duplicates in Foreach Loop

≯℡__Kan透↙ 提交于 2020-01-06 07:25:32
问题 I saw other questions that seemed like this one but they were actually quite different so I'm posting my own version. The code below, especially the form, was simplified so as to better fit. This query is being generated dynamically but has duplicates due to the fact that the date and time are being submitted using six individual fields, one for each portion of the human-readable date. Then a custom function puts these into a Unix timestamp for insertion but because it is within a foreach

php count occurences of an array field and increment the value of another field to print rows associated to ID

不羁岁月 提交于 2020-01-06 07:19:13
问题 Hello everybody Im getting headache at this question here asked before then I try now to solve in other way. Ihave a script that loops an array that put data in a CSV file, i need to count the rows with same ID and put the row number line by line. this is my scritpt that loops the array and put it in a csv file for export. public function fputToFile($file, $allexportfields, $object, $ae) { if($allexportfields && $file && $object && $ae) { //one ready for export product $readyForExport = array

Creating a statusfield for users

微笑、不失礼 提交于 2020-01-06 06:58:34
问题 I need some guidance here on why this isn't working: So here's the issue, I want to give my users a little status field so they can check how long it will take and get a coffee or two for them. My Problem is that the statusfield (2 Labels), are not updated during the process. This is my current code : private void Cancel_Click(object sender, EventArgs e) { this.Close(); } private void start_change_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Start process?",