Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-09-23T21:24:57Z
Updated: 2 hours 6 min ago

VBA code to change add value in multiple cells with right click/left click function

21 hours 43 min ago

I am new to Excel and I have a worksheet with several command buttons. I want to know if I can add value to multiple cells by left clicking (as normal) and right clicking.

For example, if I left click the command button, it adds a (+1) to cell A1, but if I right click the same command button, it adds a (+1) to cell B1.

Here is the code that I have to add (+1) when I do a normal left click:

Sub Action68_Click() 'update column BR by adding 1 to the cell value' Worksheets("Stats").Cells(CurrentPlayerRow, "BR").Value = Worksheets("Stats").Cells(CurrentPlayerRow, "BR").Value + 1 End Sub`

Is there anyway to use the right click button to add a (+1) to the cell BQ?

startActivity for result does not called on fragment

Fri, 09/22/2017 - 21:41

I'am try to use start Activity for result to pick photo from gallery but it does not called on fragment

I checked most solutions but no one work for me please help me

newsImg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { intent=new Intent(Intent.ACTION_PICK); intent.setType("image*//*"); getActivity().startActivityForResult(intent,GALLERY_INTENT); } }); @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode==GALLERY_INTENT && resultCode== Activity.RESULT_OK){ Uri uri=data.getData(); StorageReference filePath=mStorage.child("Photos").child(uri.getLastPathSegment()); filePath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { downloadUri=taskSnapshot.getDownloadUrl(); Picasso.with(getActivity().getApplicationContext()).load(downloadUri).fit().centerCrop().into(newsImg); Toast.makeText(getActivity().getApplicationContext(),"success",Toast.LENGTH_SHORT).show(); publishBtn.setEnabled(true); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(getActivity().getApplicationContext(),"fail",Toast.LENGTH_SHORT).show(); } }); }

read bmp file data as array and write it on another file C++

Fri, 09/22/2017 - 21:15

Hi I am working on bmp file.I want to read bmp file data as binary data and put it on an array in a simplest way.I have looked for sample c++ codes in internet,but every where they solved it in a bit complex way.They first found header length and others that was difficult to understand.Please help me with a code that represents the binary data of a bmp file using c++.I need to know how bitmap data can be shown in simple way.

Should I create module for each web page template?

Fri, 09/22/2017 - 21:14

I'm new to angular. I'm starting to build a website using angular 4.4.3. This website has :

  • home page
  • list page
  • detail page
  • submit form page
  • thank you page

Right now, I'm thinking what structure is good for this website. Should I use module for each page template? for example:

  • HomeModule for home page
  • ListModule for list page
  • DetailModule for detail page
  • SubmitFormModule for submit form page

... etc

Or other structure is more better? Any suggestion is helpful. Thank you very much!

Control the length of the distance in border css

Fri, 09/22/2017 - 21:14

I want to make "border" like this picture

enter image description here

Swift: how to make search bar animate when focused? Used to work?

Fri, 09/22/2017 - 21:14

Ok, I feel as though a few versions of Xcode ago this was the default, and I have it working in a past project, just do not know why I cant get this search bar animation to happen with this search bar now in Xcode 9.

What I want to happen is when the search bar ISNT focused, the placeholder text is centered:

Then when its tapped and becomes first responder, the text is left aligned (the transition between the two seems to animate automatically):

I swear search bars used to do this without any customization. How can I achieve this? Right now in my tableview custom header I set up my search bar programmatically like this:

searchBar.placeholder = "Find an Episode." searchBar.backgroundColor = UIColor.clear searchBar.searchBarStyle = .minimal searchBar.layer.shadowOpacity = 0.0 searchBar.barTintColor = thirdColorStr searchBar.tintColor = thirdColorStr searchBar.frame = CGRect(x: 0, y: 0, width: self.bounds.width, height: screenSize.height * (40/screenSize.height)) self.addSubview(searchBar) // searchBar.center = CGPoint(x: self.bounds.width/2, y: (searchBar.bounds.height/2)) searchBar.center = CGPoint(x: self.bounds.width/2, y: (searchBar.bounds.height)*0.8) searchBar.delegate = listVC for subView in searchBar.subviews { for subViewOne in subView.subviews { if let textField = subViewOne as? UITextField { subViewOne.backgroundColor = secondColorStr //print("HEREE:", textField.bounds.width/screenSize.width) //use the code below if you want to change the color of placeholder if let t = textField.value(forKey: "placeholderLabel") as? UILabel { t.textColor = thirdColorStr t.font = iphoneFontThin t.tintColor = thirdColorStr t.backgroundColor = UIColor.clear } // if let clearButton = textField.value(forKey: "_clearButton") as? UIButton { // // Create a template copy of the original button image // let img = UIImage(named: "clear") // clearButton.setImage(img, for: .normal) // // // Finally, set the image color // //clearButton.tintColor = .red // } if let t = searchBar.value(forKey: "searchField") as? UITextField { t.textColor = barColorStr t.font = iphoneFontThin t.backgroundColor = secondColorStr

Then

func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { self.searchBar.showsCancelButton = true } func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { //searchBar.showsCancelButton = true resetCategory(newCat: overallCategory) searchBar.text = "" searchBar.resignFirstResponder() //kills keyboard }

I cant find any differences between the code that produces and animation and the one above that does not.

Do I need phpMyAdmin?

Fri, 09/22/2017 - 21:13

I have a very small personal website, written with HTML editor. I have never used this feature and don't even know how, I don't have any wordpress blogs or anything written in PHP, do I need this? For some strange reason, I actually have 4 of them.... Any help is appreciated!

Failsafe doesn't execute correctly

Fri, 09/22/2017 - 21:10

I'm making a scientific notation writing program, so let me show you the code:

import time def scientific_notation(number): decimal = "" for thing in str(number): """ Loops through the number to add stuff to "decimal" (probably not necessary but i'm going to keep it there in case I need a filter.) """ if len(decimal) == len(str(number)): break else: decimal += thing decimal = decimal.replace('0','') print(decimal) while float(decimal) > 10: # Uses decimal notation actual = '' # To keep track of the original place for x in range(0,len(str(number))): actual += str(number)[x] decimal = decimal.replace(str(number)[x],str(number)[x]+'.') # Adding decimal points to each place until the float version of that is less than 10 if decimal.count('.') > 1: # if there's more than one decimal, replace that value with what it was before decimal = decimal.replace(str(number)[x],actual) elif float(decimal) > 10: # if the float version of the decimal is more than 10, wait for the while loop to realize that by doing nothing pass else: pass else: # Output power = '10^'+str(str(number).count('0')) print(decimal+" * "+power) scientific_notation(102)

Alright, now that you've looked at it let me tell you what's going on.

So, in the while loop, my if statement isn't executing

if decimal.count('.') > 1

or at least, not executing correctly and that's causing a

ValueError: could not convert string to float: '1.102.'

because my while loop tries to convert it to a float, but gets '1.102.' and raises a ValueError because you can't convert something with two decimal points into a float. Any ideas on why the if statement isn't working? I dunno, maybe i'm just being stupid.

SQL how to force to display row with 0 if no data available?

Fri, 09/22/2017 - 21:09

My table returns results as following (skips row if HourOfDay does not have data for particular ID)

ID HourOfDay Counts -------------------------- 1 5 5 1 13 10 1 23 3 ..........................HourOfDay up till 23 2 9 1

and so on.

What I am trying to achieve is to force showing rows displaying 0 for HoursOfDay, which don't have data, like following:

ID HourOfDay Counts -------------------------- 1 0 0 1 1 0 1 2 0 1...................... 1 5 5 1 6 0 1...................... 1 23 3 2 0 0 2 1 0 etc.

I have researched around about it. It looks like I can achieve this result if I create an extra table and outer join it. So I have created table variable in SP (as a temp workaround)

DECLARE @Hours TABLE ( [Hour] INT NULL ); INSERT INTO @Hours VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12) ,(13),(14),(15),(16),(17),(18),(19),(20),(21),(22),(23);

However, no matter how I join it, it does not achieve desired result.

How do I proceed? Do I add extra columns to join on? Completely different approach? Any hint in the right direction is appreciated!

Why does home_url() not work with filemtime() in WordPress?

Fri, 09/22/2017 - 21:04

I wanted to start automatically changing my enqueue version so I don't have to manually change it after a file edit so I thought about using filemtime() to pull the time but for some reason when I use it with site_url() or home_url it doesn't work:

function bootstrap_enqueue() { $bootstrap_file = home_url() . '/css/boostrap.css'; if (file_exists($bootstrap_file)) : $bootstrap_ver = date("y.m.d", filemtime($bootstrap_file)); else : $bootstrap_ver = '1.0.0'; endif; wp_enqueue_style('bootstrap-style', $bootstrap_file, $bootstrap_ver); } add_action('wp_enqueue_scripts', 'bootstrap_enqueue');

but when I pass:

wp_enqueue_style('bootstrap-style', home_url() . '/css/bootstrap.css', '1.0' );

it works. I've researched and read:

but I haven't found an answer to why filemtime() not work in WordPress with home_url?

Maximize medal count in an Array

Fri, 09/22/2017 - 21:00

I have recently started learning algorithms . Please help me solve the following question on Array:

In array of size N , every element in array contains Medal or an Athlete. An athlete can grab only one medal at maximum of K distance from him. Find a way to maximize medal count .

example:

M--> Medal

A--> Athlete

if K = 1

M A M --> Maximum medal count 1

M M M A A --> Maximum medal count 1

M A M M M A --> Maximum medal count 2

Mergin two arrays but keep indexes

Fri, 09/22/2017 - 20:57

So I have these two arrays that I need to merge into one and keep the indexes. I tried different things like array_merge, array_merge_recursive, etc but I couldn't figure it out.

array(3) { [0]=> string(4) "Peter" [1]=> string(4) "Josh" [2]=> string(4) "Jasper" } array(3) { [0]=> string(2) "18" [1]=> string(2) "19" [2]=> string(2) "25" }

This is how I want it to look like:

array(3) { [0]=> array(2) { ["name"]=> string(5) "Peter" ["age"]=> int(18) } [1]=> array(2) { ["name"]=> string(4) "Josh" ["age"]=> int(19) } }

Any ideas how I can achieve this?

C# Dynamic full outer join on 2 datatables

Fri, 09/22/2017 - 20:43

I need to do a full outer join on 2 datatables dinamically, I don't know what columns are in the datatables but they will be the same in each table, I also only have the name of the column I need to do the join on in a variable. Is there a way of doing this?

How to break up a long string in multiple lines in a windows batch file while still allow cmd.exe to parse it as a single argument?

Fri, 09/22/2017 - 20:43

I have a Windows batch file for cmd.exe. It has a single line of code to invoke the PowerShell Send-MailMessage cmdlet and exit back to cmd.exe. Currently the line reads like:

PowerShell -Command "Send-MailMessage -To one.person@somewhere.com, another.person@sameplace.com -Subject 'A rather lengthy text' -From info@my.com -SmtpServer hostname.subdomain.mycompany.com -UseSsl -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'UserName',('SecretePassword1234'|ConvertTo-SecureString -AsPlainText -Force)) -Body 'A static text.'"

It works great. But I find it difficult to edit it in NotePad or any text editor because the line is way too long. What I want is to use the CMD.EXE's caret ^ character to break up the long string within the double quotes into multiple lines. However, the PowerShell.EXE command requires that:

PowerShell -Command <string>

The above syntax requires that CMD.EXE parse everything after -Command to be a SINGLE string, aka a single argument. I've tried the following that didn't work:

PowerShell -Command "Semd-MailMessage Blab Blab " ^ "More Blah Blah"

If I break up the line in my batch file as above, CMD.EXE will parse the first part of the string as one argument, and the string on the next line as another argument. Wrong. So what should I do?

PHP Search Array With Multiple Keywords And Sorted Result

Fri, 09/22/2017 - 20:30

I have a plan to make search from txt file that I prepare, the txt file content similar like this below

a.txt

Amy Jefferson Nathalie Johnson Emma West Donna Jefferson Tanya Nathalie George West Emma Watson Emma Jefferson

If the code was like this

a.php

$filename = "a.txt"; $example = file($filename, FILE_IGNORE_NEW_LINES); $searchword = 'Emma Jefferson'; $matches = array(); foreach($example as $k=>$v) { if(preg_match("/\b$searchword\b/i", $v)) { $matches[$k] = $v; echo $matches[$k]."<br>"; } }

The result will only "Emma Jefferson"

Then if i use this code

b.php

$filename = "a.txt"; $example = file($filename, FILE_IGNORE_NEW_LINES); $searchword = 'Emma Jefferson'; $matches = array(); foreach($example as $k=>$v) { $searchword2 = str_ireplace(" ", "|", $searchword); if(preg_match("/\b$searchword2\b/i", $v)) { $matches[$k] = $v; echo $matches[$k]."<br>"; } }

The result will be like this

Amy Jefferson Emma West Donna Jefferson Emma Watson Emma Jefferson

Unique result, but "Emma Jefferson" in the last result

So the question is how I can search Emma Jefferson, the result sort was like this

Emma Jefferson Emma Watson Emma West Amy Jefferson Donna Jefferson

So basically it search for "Emma Jefferson" entire word first, then "Emma" and the last one is "Jefferson"

Excel - filter table results by dates

Fri, 09/22/2017 - 20:10

I have a refreshable table in excel and I want to filter the rows by a couple of date ranges. Each row has a date and other information.

I want to find the rows that are in the first date range (F1:F2) and are not in the second date range (H1:H2).

The table is refreshable, and can change size. It currently spans A3:X6146. The table is a query, so it will change sizes when a separate date range is used to find the table values.

I don't have much VBA experience, so this problem is tripping me up. Any ideas?

Thanks

everything looks fine but query not working [duplicate]

Fri, 09/22/2017 - 19:59

This question already has an answer here:

mysqli_query($conn,"insert into order (fabricator_id,user_id,refrence_number,fname,customer_category,company_name,attention,attention_category, date,property_type,property_no,sector,street,block,city,area,cphone,aphone,email,referby_name,referby_number) values('$get_id','$session_id','$refrence','$fname','$category','$company','$attention','$attention_category',Now(), '$ptype','$pno','$sector','$sno','$block','$city','$area','$cphone','$aphone','$cemail', '$rname','$rphone')") or die(mysql_error());

value from all the variables are ok the problem is query not inserting values in database...Please suggest Something am not getting any error and am not using any reserved keyword

Unable to set SESSION CHARSET to UTF16 in BTEQ

Fri, 09/22/2017 - 19:37

I have a file that I need to execute within BTEQ that is formatted in UTF16 with BOM. However I get the following error when I try to set the CHARSET before running the file:

.SET SESSION CHARSET 'UTF16'; *** Error: SET SESSION CHARSET UTF16 is not allowed.

I can set this to UTF8 and convert the file to UTF8 and it works. I also can convert the file to UTF8 without BOM and not set CHARSET the script runs. This file is system generated and I'm automating this script deployment so converting the document is not preferred.

Get place in table of icon using ng-click

Fri, 09/22/2017 - 19:27

I have a table that's generated using ng-repeat with some columns headers. On the column headers, I want to columns to be sorted. I included a font-awesome sort icon next to their text and when it's clicked, I call an ng-click with ng-click="sortColumn()". I'm calling this for every column header.

How do I know which column header got clicked on? Right now it fires for each header column.

How do pass the current column in using ng-click?

I tried to pass in this, but it returns the $scope object.

Here's what I have so far:

HTML:

<table class="table"> <thead> <tr> <td><b>Product </b><i class="fa fa-sort" ng-click="vm.sortColumn(this)"></i></td> <td><b>Code </b><i class="fa fa-sort" ng-click="vm.sortColumn(this)"></i></td> <td><B>Available </b><i class="fa fa-sort" ng-click="vm.sortColumn(this)"></i></td> <td><B>Price </b><i class="fa fa-sort" ng-click="vm.sortColumn(this)"></i></td> </tr> </thead> <tbody> {{ vm.noProducts }} <tr ng-repeat="product in vm.products"> <td>{{ product.productName}}</td> <td>{{ product.productCode }}</td> <td>{{ product.releaseDate | date }}</td> <td>{{ product.price | currency }}</td> </tr> </tbody> </table>

Javascript:

vm.sortColumn = function (obj) { console.log(obj); }

End of Array Function Not Working Correctly in Google Apps Script

Fri, 09/22/2017 - 18:21

I have written a custom function in google apps script that takes the values from a spreadsheet in the form of a 2D array, and loops through them checking if the values are undefined or an empty string. However, I am getting that the first value is equal to an empty string, when it is certainly not. I am also getting that the value is NOT equal to an empty string, which doesn't make any sense at all. The value of the first

Here is my code:

function lastColumnWithValue(row, cells) { var i = 0; //cells[row][i] = 0 to start with //not getting into while loop Logger.log(cells[row][i]); Logger.log(cells[row][i] === ""); Logger.log(cells[row][i] != undefined && cells[row][i] != "") Logger.log(cells[row][i] != undefined); Logger.log(cells[row][i] != "")//returns false Logger.log(cells[row][i] === "")//returns false while (cells[row][i] != undefined && cells[row][i] != "") { i++; } Logger.log("i - 1: " + (i - 1)) return i - 1; }

Pages