Question: I'm attempting to describe running ec2 instances that I'm using with the following code:

```
DescribeInstancesResult describeInstancesRequest = ec2.describeInstances();
            List<Reservation> reservations = describeInstancesRequest.getReservations();
            Set<Instance> instances = new HashSet<Instance>();

            for (Reservation reservation : reservations) {
                instances.addAll(reservation.getInstances());
            }

            System.out.println("You have " + instances.size() + " Amazon EC2 instance(s) running.");

```

I'm getting a return result of 0. I'm guessing this is because the default AZ is set to US-East.

My instances are running in US-West.

How do I change the AZ?

Answer: 
Most likely `row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS).Text` is not returning what you expect. If it has anything other than 0-9 or value larger than `int.MaxValue` you'll get an exception. Additionally `null` or `System.String.Empty` will cause an exception.

You can use `TryParse` instead which will return a bool indicating whether or not the parse worked. If it works, the int you pass in will be set to the string you pass in.

To give some actual code;

```
if(!int.TryParse(row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS).Text, out renewalGracePeriodDays))
         renewalGracePeriod = MyDefaultValue;

```
It's possible that the column you are checking is either an empty string, or contains non-integer data. I recommend using the TryParse method.

```
int renewalGracePeriodDays;
if (!int.TryParse(row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS).Text), out renewalGracePeriodDays)
{
    renewalGracePeriodDays = 0;
    // Inside here, you can log the exception, alert the user, or end processing
}

```

If the TryParse fails, your grace period will default to 0. It's a good idea to use this method when dealing with user inputs, because there's no telling what people will enter, even when properly prompted...