mercredi 1 mars 2017

Copy Cells using IF for non -blank values

I have a table where there are 3 columns which have blanks in them . I want to copy the non blank values to suppose D2. Say I have blank in C2 , B2 is not blank , then the value to be copied is B2 . If both C2 and B2 are blank , then value to be copied is A2. I am using the following formula:

=IF(C2="",B2,IF(B2="",A2, C2))

It is running correctly for the values where C2/B2 values are blank . But it throws up a 00-01-1900 Value in D2 when both the C2 and B2 cells are blank and I want only A2 data in the cell . Is there some way to resolve this ?

PHP refactor if else

I have this if else structure and I want to refactor the else out since I want to clean up the code a bit. Only I am not sure how I can refactor the else out.

if ($validator->fails()) {
   return Redirect::back()
       ->with('error_code', 5)
       ->withErrors($validator->errors())
       ->withInput();
} else {
    // do something if validator does not fail
    return Redirect::back();
}

Anyone has any idea how I can refactor the else out?

Many thanks in advance!

Condition check in async method

Question description: I am surprised that code inside the if block is reached. I supposed the if block won't be executed.

I am totally confused. Who can explain or teach me?

private async Task TestMethod()
{
    bool ok = false;
    City city = City.BJ;
    await Task.Delay(100);
    ok = true;

    if (!ok)//Suppose it won't go into this code block. Because variable 'ok' is true.
    {
        if (city == City.BJ)//City is enum type.
        {
            throw new Exception("BJ. Good day.");
        }
        else
        {
            throw new Exception("SH. Rainy day");//This row is reached.Weird! But the upper caller method doesn't detect this exception.
        }
    }
}

enum City
{
    BJ = 1,
    SH = 2
}

JS: Changing value in function doesn't work

I've made an which displays a arrow pointing down. The idea is that if the user clicks on this, the navigation bar will be shown. So far it works but I wanted that when the is pressed, it's value and rotation changes as well. However the value doesn't change. Can someone please help me with what i'm doing wrong. Thanks!
The screenshots:
Javascript code which doesn't work
HTML that belongs to the Javascript

Retrieving string for if/else clause in android studio

im trying to get a qr code scanner going where it should redirect to different activities in dependancy on the code scanned but im having trouble getting the string from the result in the correct form, thanks in advance

  @Override
public void handleResult(Result result) {
    Log.w("handleResult", result.getText());
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Scan results");
    builder.setMessage(result.getText());
    AlertDialog alertDialog = builder.create();
    alertDialog.show();

    String id_helper = result.getText().toString();

    if (id_helper == "1") {
       startActivity(new Intent(this, Sample1.class));
    } else if (id_helper == "2") {
        startActivity(new Intent(this, Sample2.class));
    } else {
        startActivity(new Intent(this, Sample3.class));
    }

how to use if statement in asp:repeater ItemTemplate

I know how to use if statement in ItemTemplate, such as <%#Eval("ID")==0?"aaa":"bbb"%>

but, in my code, I also have a question.

I binded the data to repeater,but in the row one, the column"tuijian" is DBNull.

<asp:Repeater ID="repALL" runat="server">
<ItemTemplate>
    <div class="table_style2">
        <%
            object objComID = ((System.Data.DataTable)repALL.DataSource).Rows[_nIndex]["ComID"];
            object objJoinID = ((System.Data.DataTable)repALL.DataSource).Rows[_nIndex]["JoinID"];
            _nIndex++;
            if (objComID != System.DBNull.Value)
            { %>
        <%# Convert.ToInt32(Eval("tuijian"))%>
        <%}
            else if (objJoinID != System.DBNull.Value)
            { %>

        <%#Convert.ToInt16(Eval("ID"))%>
        <%} %>
    </div>
</ItemTemplate>

so the code is error on <%# Convert.ToInt32(Eval("tuijian"))%>.

I rewrite the code like

<asp:Repeater ID="repALL" runat="server">
<ItemTemplate>
    <div class="table_style2">
        <%
            object objComID = ((System.Data.DataTable)repALL.DataSource).Rows[_nIndex]["ComID"];
            object objJoinID = ((System.Data.DataTable)repALL.DataSource).Rows[_nIndex]["JoinID"];
            _nIndex++;
            if (objComID != System.DBNull.Value)
            { %>                            
                    <%# Convert.ToInt32(Eval("ID"))%>                                    
        <%}
            else if (objJoinID != System.DBNull.Value)
            { %>

                    <%#Convert.ToInt16(Eval("ID"))%>
        <%} %>
    </div>
</ItemTemplate>

the results can be showed in the web.

mardi 28 février 2017

How to make if statement true every four loops in Python

I am not sure on how to ask this question, i have searched but no results. Please help.

How can I make an if statement which will repeat itself every four times insede a for loop:

for x in range(0,20):
     print x
     if x >= 3:
         print ","

As you can see here I want the comma to reap evry four numbers and instead i get this:

0
1
2
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
.
. 
.

Since the numbers ahead of 3 are greater than 3. I am on python. Please help me.