VBA If-statement with AND Operator [closed] - vba

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am using the following code which works perfectly:
If ComboBox3.ListIndex = 0 And ComboBox4.ListIndex = 3 Then
ID1 = "GS-T10-"
Elseif ComboBox3.ListIndex = 0 And ComboBox4.ListIndex = 4 Then
ID1 = "PB-"
Elseif ComboBox3.ListIndex = 0 And ComboBox4.ListIndex = 5 Then
ID1 = "PE-"
As you can see It is if statement with AND operator evaluating 2 conditions.
However notice that my first condition is always the same (ComboBox3.ListIndex = 0), and only the second condition is changing. Is there a way to just write the first condition (which is not changing) once at the beginning of the IF Statement and hence only write the second condition after each Elseif??
Thank you,

You should "take out" the repeating condition to outer If statement, like this:
If ComboBox3.ListIndex = 0 Then
If ComboBox4.ListIndex = 3 Then
ID1 = "GS-T10-"
Elseif ComboBox4.ListIndex = 4 Then
ID1 = "PB-"
Elseif ComboBox4.ListIndex = 5 Then
ID1 = "PE-"
End If
End If

Related

Duplicate values pandas [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am new to pandas.
I have been trying to solve a problem here
This is the problem statement where I want to drop any row where I have a duplicate A but non duplicate B
Here is the kind of output I want
enter image description here
IIUC, this is what you need
a = (df['A'].ne(df['A'].shift())).ne((df['B'].ne(df['B'].shift())))
df[~a].reset_index(drop=True)
Output
A B
0 2 z
1 3 x
2 3 x
I think you need:
cond=(df.eq(df.shift(-1))|df.eq(df.shift())).all(axis=1)
pd.concat([df[~cond].groupby('A').last().reset_index(),df[cond]])
A B
0 2 y
2 3 x
3 3 x

Constant values in Fortran [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an input file to read values from and one such value is 1d10.
How to make sense of that value?
The input file is below and its for LU factorization:
8000 8000 8000 1d10 120 120 8
The variables above are:
min_n max_n stepsize total_flops_in_timing_block blower bupper bstride
Assuming all of those values are integers except for the flops variable, this example code will work. Also note this depends on the fixed width of your input file and the values being separated by a single space. If you have more general needs this will need tweaking to work.
program test
implicit none
integer :: n_min, n_max, n_step, b_low, b_high, b_stride
integer :: ufile
real(kind=kind(1d0)) :: flops
open(newunit=ufile, file="input2.txt", access="sequential")
read(ufile,*) n_min, n_max, n_step, flops, b_low, b_high, b_stride
close(ufile)
print *, "min_n = ", n_min
print *, "max_n = ", n_max
print *, "stepsize = ", n_step
print *, "flops = ", flops
print *, "blower = ",b_low
print *, "bupper = ", b_high
print *, "bstride = ", b_stride
end program test
Given the input file:
8000 8000 8000 1d10 120 120 8
produces this output:
% ./read_input
min_n = 8000
max_n = 8000
stepsize = 8000
flops = 10000000000.000000
blower = 120
bupper = 120
bstride = 8

Check if a date exists in a pandas dataframe [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Date Signal
1 2008-05-28 11:00:00 1.886108
2 2008-04-17 12:00:00 1.885108
3 2008-05-21 12:00:00 1.166525
4 2008-05-28 11:00:00 1.166525
5 2008-05-23 11:00:00 1.010902
Hi, is there a way I can match the above dataframe to a date, eg 2008-05-28 11:00:00 and print only the Signal value if it matches?
thanks in advance.
* apologies if this was a niave question. I tried many various methods but not .loc which has been kindly pointed out below and works perfectly, thank you.
Assuming you have data frame df
d = pandas.Timestamp("2008-05-28 11:00:00", tz=None)
df[df.Date == d].Signal
You can use loc too:
df.loc[df.Date == '2008-05-28 11:00:00', 'Signal']
Not tested but something along the lines of...
df['Signal'][df.Date == '2008-05-28 11:00:00']

How to find lines of objective c method implementations using libclang [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I want to get the line numbers where the implementation of objective c method start.
1 #include "foobar.h"
2 -(void)Foo{
3 ...
4 }
5
6 +(NSInteger *)bar{
7 ...
8 }
The output should be: 2,6
How can i achieve it with libclang.
I do not want to use a regex for that, because it will be sufficient.
Solution:
CXSourceRange range = clang_getCursorExtent(cursor);
CXSourceLocation startLocation = clang_getRangeStart(range);
CXSourceLocation endLocation = clang_getRangeEnd(range);
CXFile file;
unsigned int line, column, offset;
clang_getInstantiationLocation(startLocation, &file, &line, &column, &offset);
enum CXCursorKind curKind = clang_getCursorKind(cursor);
CXString curKindName = clang_getCursorKindSpelling(curKind);
const char *funcDecl="ObjCInstanceMethodDecl";
if(strcmp(clang_getCString(curKindName),funcDecl)==0){
printf("%u",line);
}

Can someone help me with this pattern [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I can't figure out this simple(?) pattern in vb.net.
So the problem is this: I have 4 arrays of integers, 2 of them are from 0 to 29, and the last 2 are from 0 to 9. Now I am trying to make the pattern look like this:
I hope it makes sense.
This simple LINQ-query should give you the expected result.
Dim big1 = Enumerable.Range(0, 30).ToArray()
Dim big2 = Enumerable.Range(0, 30).ToArray()
Dim small1 = Enumerable.Range(0, 10).ToArray()
Dim small2 = Enumerable.Range(0, 10).ToArray()
Dim result = From b1 in big1
From b2 in big2
From s1 in small1
From s2 in small2
Select New With {b1, b2, s1, s2}
...
It uses the Enumerable.SelectMany function:
Enumerable.SelectMany
Projects each element of a sequence to an IEnumerable and flattens the resulting sequences into one sequence.