2011年7月10日

【App Store】+ on App

The + symbol in the front of Apps in App Store indicate that

the application is a universal app, which means that the app is

designed for both the iPhone and the iPad.

You just pay one time then can download in iPhone and iPad.

2011年7月6日

【C#】Truncate the string

當字串太長時,若要擷取某一部份的字串時,通常會使用
String.substring(int32 a, int32 b)方法,從第
a個位置開始,取得長度為6的字串。
但若是中英夾雜的字串,用此方法可能會擷到中文字的一
字元,此時就需另一個判斷方式。


string str = "I'am 中文字";
int maxLength = 8; //擷取長度為7byte的字串
string result='';
int count = 0;
foreach(char a in str)
{
     counter = counter+ System.Text.Encoding.GetEncodeing("Big5").GetBytes(str.ToString()).Length;
     if(count <= maxLength)
     {
            result = result + a;
     }
     else
     {
            break;
     }
}
System.Writeline(result+"...");

2011年6月29日

【Excel】How to 四捨五入

1. ROUND Function

ROUND(number, num_digits)

。number:想要執行四捨五入計算的數字。

。num_digits:對數字引數執行四捨五入計算時的位數。

EX:
。ROUND(A1,3)=12.346 //A1=12.3456789

。ROUND(A1,-1)=10

2. 設定儲存格格式

格式->儲存格格式->數值分頁->"數值"or"貨幣"

2011年6月20日

【C#】Decimal型別

decimal 關鍵字表示 128 位元的資料型別。相較於浮點型別,decimal 型別有較高的精確度和較小的範圍,讓它非常適合財務和金融計算。

常值:

         如果要將數字實數常值宣告為decimal處理,請使用後置字元 m 或 M,例如:
         
decimal myMoney = 300.5m;

         如果沒有後置字元 m,數字會被視為double處理,因而產生編譯器錯誤。

 轉換:

         整數類資料型別 (Integral Type) 隱含轉換成 decimal,無須在後置字元,如下:
   
decimal myMoney = 300;

        但float與decimal之間並沒有隱含轉換,因此,這兩種型別之間的轉換 (Conversion) 必須使用轉換 (Cast);
decimal myMoney = 99.9m;
double x = (double)myMoney;
myMoney = (decimal)x;

範例:
decimal d = 9.1m;
int y = 3;
Console.WriteLine(d + y);   // Result converted to decimal, 12.1

2011年5月26日

【Android】Layout 屬性

Android基本的Layout屬性很多,其中最常看到的是UI元素長寬之fill_parent與wrap_content,但有時還是搞不懂是UI元素的屬性,還是元素中文字的屬性。以android:layout_gravity與android:gravity來看,有加layout是指元素本身相對於它的父元素而言,它顯示的位置:

android:layout_gravity="left"

2011年5月22日

【Blogger】Use SyntaxHighlighter for Blogger

想要讓Source Code快速且美觀地呈現在Blogger上,就非SyntaxHighlighter」莫屬了,去官網發現已經更新到 3.083了,裡面也有詳細說明SyntaxHightlighter安裝的步驟,一般都而言都是先下載套件,再上傳到WebSite上,但Blogger使用者有福了,SyntaxHighlighter有「Blogger教學手冊」並提供Link可以直接用,省去下載&上傳的步驟。
  1. Go to Blogger Dashboard > Design > Edit HTML.
  2. Press CTRL+F to find the code 
  3. Copy the below code