ãªãVBã¯C#ã¨æ¯ã¹ã¦é§ç®ãªã®ã
æ¥å¹´3æã§1.5å¹´ã»ã©åããç¾å ´ãå»ããé常ã«åããããè·å ´ã ã£ãããå¨å²ã®äººéãã¿ããªè¯ã人ã°ããã ã£ããæ®æ¥ããããªãã«ãã¦520ä¸ç¨åº¦ã ãåå
¥é¢ãã極ãã¦å®ããã¨ãã訳ã§ããªãã£ã(2015/6追è¨ããã£ã±å®ã)ãã ããããã§ã®çµæ´ãå®ç¸¾ã¯ããASP.NETãã¨ã ãæ¸ããããã³ããµã¤ã(ã¬ã¹ãã³ã·ããã¶ã¤ã³ãã¬ã¬ã·ã¼ãã©ã¦ã¶ãSNSé£æº)ãPL/SQLã®ãããä½æãªã©ã®ææã®ã¿ãæ®æ´å¼·èª¿ãããµã¼ãã¼å´ã®è¨èªã«ã¤ãã¦ã¯ãã¾ã触ããªãããã«ããããä½æ
ãã¨ããã¨VBã ããã
ãVB.NETã¯C#ã®æ¹è¨ãã¨ããè¦æ¹ãå¼·ããªã£ã¦ãããæ´å²çã«è¦ãã°ãããDelphiããç£ã¾ãã¦ãJavaã¨C++ãåé¢æ師ã¨ãã¤ã¤ä¸é¢ãæåãã2002å¹´ã«1.0ãç»å ´ã®C#ããããBASICããé£ãªãVBã®æ¹ãå ¨ç¶å¤åã ãæ±äººæ°çã«ãVBã®æ¹ãå¤ãããã«è¦ãããå ãã¦ãè¨èªä»æ§çã«ãC#ã§åºæ¥ãäºã¯åºæ¬çã«VBã§ãã»ã¼å¯è½ã ãVBã§ããåºæ¥ãªã(åºæ¥ãªãã£ã)ãã¨ãããããªã®ã«ä¸é¨ã«VBãä¸ã«è¦ãåããæãã®ã¯ããããªãã®çç±ããã£ã¦ã®ãã¨ãããã¦ä¿ºãæ¼ããªãVBã¯å¥½ãã§ã¯ãªãã»ã»ã»ã©ãããå«ããªè¨èªå§åçNo.1ã§ãããä»å¾ã¯äºåº¦ã¨VBã®æ¡ä»¶ãåãããã¨ã¯ãªãããèªåããã1.5å¹´ãã®éVBãæ¸ãç¶ãã¦ããã¨ããäºå®èªä½ããé»æ´å²ã¨ãããã
VBã¨C#ã¯åæ¹ã¨ã.NETãã¬ã¼ã ã¯ã¼ã¯ã«åºãã¦ããããæ©è½å·®ã¯ä»ã§ã¯ã»ã¨ãã©ãªããILã«å¤æãããã¨ã¯çè«çã«ã¯é度差ããªãã¯ãã ãããããã両è ãæ··å¨ãã¦æ¸ããã¨ãã§ããå å¼ãå§å¦¹ã¿ãããªè¨èªã ãã ãã©ãããC#ãVBãã§ä½ãããã¸ã§ã¯ããå§ããæ©ä¼ãããã¨ãããC#ãé¸ã¶ãã¨ãå¼·ãè¦ãããã¾ãVBãæ¬è·ã®ã¨ã³ã¸ãã¢ãªãããé¢æ¥ã«æ¥ãããçã£å ã«è½ã¨ãã¦æ¡ç¨ããªãæ¹ããããéã«ã¨ã³ã¸ãã¢ããããã°ãä»®ã«C#ã¨VBã®ä¸¡æ¹ã®æ¡ä»¶ã«å°±ããæ©ä¼ã転ãã£ã¦ããã¨ãã¦ãå価ããã»ã©éããªã©ã®äºæ ããªãéãã¯C#ã®ããã¸ã§ã¯ããé¸ãã æ¹ãããã
ããããªããVBæ´ã®é·ãã¨ã³ã¸ãã¢ã ã¨ããããèå©å¿ãªããITä¸çã®æ½®æµã¨èªåã¨ã®ç«ã¡ä½ç½®ãä¸åº¦å·éã«èãããã¨ãè¦ããããæããããã¾ã§Sierãªã©ã§å¸¸é§ãã¦åããã¨ãå¤ãã£ãã¨æããããã身ã«æã¿ã¤ãã¦ããæ £ç¿ãä½æ³ããããããã³ã¼ãã®æ¸ãæ¹ã¨ãã表é¢çãªãã®ããä»äºã«å¯¾ããã¢ããã¼ãå ¨ä½ã¾ã§ã極ãã¦ä¸åçãã¤éå¹ççãªãã®ã«ãªã£ã¦ãããããããæ¥æ¬ã®ãåæ¹ãç¾å ´ã§ããéç¨ãããªããããªäººæã«ãªã£ã¦ããå±éºæ§ãé«ãæ©æã«VB以å¤ã®ã¨ã³ã·ã¹ãã ã«è§¦ãã¦ãã©ãã¤ã ã転æããªãéããã¨ã³ã¸ãã¢ã¨ãã¦å¤§æãããã¨ã®é害ã«ãªããããªãã
ãªãããã¾ã§ä¿ºã¯ææ çã«VBãå«æªããã®ããæ£ç´ãä¸æå¿«ã«æããåããããã ããããã ã俺ã¯3-4å¹´ã»ã©VBã«è§¦ãã¦ãã¦ãVBã§ä½ãããããã¸ã§ã¯ãã沢山è¦ã¦ããããããããåãã¦è§¦ããè¨èªãVB(A)ã ããããåæå«æªã§ããã¨ããéå»ã®èªåãå¦å®ãããã¨ã§ä»ã®èªåã¯æé·ãã¦ããã¨ç¹ãèå¢ã ã¨è¨ããã¦ãããã¯å¦å®ããªããããã§ããªããä¸äººã®ç·ãVBããããã°ã©ãã³ã°ã«å ¥ããããã¦VBãå®å ¨ã«æ£ã¦ããã¨ã«ãªã£ãã®ã«ã¯ãç¸å¿ã®è¦æ©ã¨ã¹ãã¬ã¹ã¨å¹»æ» ã¨å¤±æãããã
é·ãã¨ã³ããªã¼ãªã®ã§æåã«æã£ã¦ããã¨ãç¾æç¹ã§ã¯VB.NETã¯æ¯è¼çããåºæ¥ã¦ããè¨èªã¨è¨ããããå¾ãªãã®ã§ãVBãé§ç®ãªçç±ãã¨ãã¦èªãã«å¤ããã®ã¯â â¡â¢â£ã¨ãã¨â¤ç¨åº¦ã§ããããã¨ã¯éç®±ã®é ãã¤ã¤ããããªé£çã«çãããã¾ãâ â¡â¢â£ã§è¨ããããã¨ã¯ãVBã ãã§ãªãä¸é¨ã®C#(æ´ã«è¨ãã°ãJavaã¨ãPHPã¨ã)ã®ç¾å ´ã«ã大ãã«ãã¦ã¯ã¾ãããã ãããã決ãã¦VBã«ã¾ã¤ãã100%ãå¦å®ããC#ã®100%ãè¯å®ãã趣æ¨ã§ãªããã¨ã¯äºãç³ãä¸ãããã
éæ§é å(BASIC)ã»æç¶ãå(VB)æ代ã«èç©ãããè² ã®æ´å²ããã
ç¾å¨ã®éçåä»ãè¨èªã®æ½®æµã¯ãæç¶ãåãããªãã¸ã§ã¯ãæåã«ç§»è¡ãããã¨ãé¢æ°åè¨èªã®è¦ç´ ãåãè¾¼ã¿ã¤ã¤ãåçè¨èªã®ããã«åé·æ§ãæé¤ãã¦ããã¨ã³ã¸ãã¢ãæ°æ¥½ã«æ¸ãããã®ã«ãã¨ããæ¹åæ§ã«åãã£ã¦ããã¨è¨ãããéã«è¨ãã°ãè¤æ°ã®æ¸ãæ¹ãã§ãããã«ããã©ãã¤ã æ§ãæããåé·ãªæ¸ãæ¹ããç°¡ç´ ãªæ¸ãæ¹ã¾ã§æ°æ§ã®ã·ã³ã¿ãã¯ã¹ãå ¥ã交ãã£ã¦ããã®ã§ã人ã«ãã£ã¦æ¸ãæ¹ã«èªç±ã¨è£éããããããã«ã³ã¼ãã®å質差ãåºãã¨è¨ããã
VBã®ç¥å
ã¯åå¿è
ç¨ã®è¨èªã§ããBASICã§ããããå½æã®ããã°ã©ãã³ã°ã®ä¸»æµã¯éæ§é åããã°ã©ãã³ã°ã§ãããGoTo
ã®å¤ç¨ã«ããã¹ãã²ããã£ã³ã¼ãã¨è¨ããããã®ãéç£ããã¦ããã¨ããããä¸é¨ã§ã.NET以éã¯å¥è¨èªãã¨ãããããæªã ã«GoTo
ãOnError
ãªã©ãæ®ãã¦ããããã«ãVBã¯BASICããå®å
¨ã«è±å´ãããã¨ã¯ãªããæ¢ãã¦éå»ã®éºç£ãæ®ãã¦æ¿ç¶ãããã¨ã§çãé·ããã¦ããã®ã§ããã
BASICã¯.NETã«ãªãåã«Visual Basicã¨ãã¦æç¶ãåè¨èªã¨ãã¦æçãããã¨ã«ãªããå½æã®æ¥æ¬ã§åºã人å£ã«è¾çãã¦ãããã§ä¸æ¦æ £ç¿ã¨å¸¸èãå½¢æããããã¨ã«ãªã£ãããããã1998å¹´ã«ãªãªã¼ã¹ããã6.0ã«æ¼ãã¦ãããªãã¸ã§ã¯ãã¨éãªãã¸ã§ã¯ããæ··å¨ãããªã©æç¶ãåè¨èªã¨ãã¦ã®å´é¢ãè²æ¿ãã(ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®å®è£ ãã©ãã¯5.0ã§å°å ¥ãããã)ã¯ã©ã¹ã®ç¶æ¿ãã§ããªããªã©ãåãããªãã¸ã§ã¯ãæåè¨èªã¨ãã¦ã¯ä¸å®å ¨ã ã£ãC++ãJavaã¨æ¯ã¹ã¦ãããå®æ度ã«ã¯åé¡ã®ããè¨èªã ã£ããã¨ã¯å¦å®ã§ããªãã
ä»ã§ãVBA(å®è³ªVB6.0)ã§ããã°ã©ãã³ã°ãããã°ãVBã¨ããè¨èªããåºæ¬çã«æç¶ãåã§ãããã¨ã¯ç解ã§ããã¨æããã.NETã«ãªã£ã¦ããstatic
ã®ããã«ãã¡ã½ããå
ã§å¤æ°ã®å¤ããã¼ãããã¨ããå¡ããªãã¸ã§ã¯ãæåãæ³å®ãã¦ããªãä¸æè°ãªãã¼ã¯ã¼ãããããã¡ã³ãã¼å¤æ°ã«å¤ãä¿æã§ãããªãã¸ã§ã¯ãã§ã¯ãªããã¡ã½ãã(ããã·ã¼ã¸ã£)ãVBã®åºæ¬åä½ã ã£ãé ã®åæ®ã (VBãæç¶ãåè¨èªãããªãã¸ã§ã¯ãæååè¨èªã«ç§»è¡ããã¾ã§ã®æµãã¯ãããããµã¤ã*1ãåç
§)ã
VB6ã¯éçåã¥ãè¨èªã§ã¯ããããIDEã貧ç¸ã§ãããã³ã³ãã¤ã«æã®ã¨ã©ã¼ãã§ãã¯ã¯åã¾ã§ã¯è¦ã¦ãããªãã£ãããã®å½±é¿ã§ãã³ã¬ãªã¢ã³è¨æ³(strTextBoxText
ã¨ã)ãå¤ãæ¡ç¨ããã¦ããã¨æããããã俺ãè¦ãVB.NETã使ãç¾å ´ã®100%ã¯ä»æ¥ããã¾ã ãã³ã¬ãªã¢ã³è¨æ³ãæ¡ç¨ãã¦ããã軽快ãªãªã¢ã«ã¿ã¤ã ã³ã³ãã¤ã«ãã§ãã¯ããããåªç§ãªè£å®æ©è½ãæã¤VSã«ããã¦ããã³ã¬ãªã¢ã³è¨æ³ãç¨ããå¿
è¦æ§ã¯ä½å¦ã«ããã®ãã¨ã¯æããããä½ãåççãããä½ãæå³ãããããã¨ãããã¨ãããããVBã¯ããããã¹ããã¨ããäºã決ã¾ã£ãæåã¨æ
£ç¿ãåå¨ããã
ããããVB.NETã«è³ãåã®Visual Basicã®ç©å¹´ã®éå»ã®æ £ç¿ã¨å¸¸èã¯ãå¹´é ã®äººéãåå¿è ã«ãåãå ¥ãæãã¨ããæ£ã®å´é¢ãããããç¡è¦ã§ããªãè² ã®å´é¢ã®æ¹ãè²æ¿ãåºã¦ãã¾ã£ã¦ãããC#ã§ãæç¶ãåæåã®ã³ã¼ããæ¸ããã¨ãå¯è½ã ãæ®å¿µãªãã¨ã«ããããç¾å ´ãããã®ãäºå®ãªã®ã ããVBã«é¢ãã¦ã¯æ®æ´LINQãåæ¨è«ãã©ã ãå¼ã©ãããããªãã¸ã§ã¯ãæåãã使ç¨ãã¦ã³ã¼ããæ¸ããã¨ã¯éªéã¨ããé°å²æ°ãããããã³ã¼ãã®ä¸å¿ã¯æ°åè¡ã«ãåã¶ã¡ã½ãã(ããã·ã¼ã¸ã£)ã§ãããã¯ã©ã¹ã¯åãªããããå²ãå ¥ãç©ã¨ããã®ãVBã®åºæ¬çãªã¹ã¿ã¤ã«ã ã
é¢æ°åã§ããªããªãã¸ã§ã¯ãæåã§ããªãä¸å¿æ§é åã¯ããã¦ããããé·ã£ãããããããããã¤ã¦VBã¨ããè¨èªãããã§ãã£ãããã«ãVBãç¨ããç¾å ´ãã¨ã³ã¸ãã¢ã¯æ¦ãã¦åé·æ§æåãªã®ã§ãããä¸æ¦ã³ã¼ããæ¸ãããå ¨ãåããã¨ãã³ã¡ã³ãã ãã§ãªããã¨ã¯ã»ã«æ¹ç¼ç´ã§åºæ¥ãèªç§°è¨è¨æ¸ãèªåã®æ¥å ±ã«ãæ¸ããªãã¨ãããªãVBã®ç¾å ´ãçããã¯ãªããããããã³ã¼ãã£ã³ã°ã«æ¼ããåé·æ§ã¯ãå¡ãä¿å®æ§ãä¸ãã¯ãããã®ã®ãå®å ¨æ§ãä¸ãããã¨ã¯ãªãã
ã¦ã¼ã¶å±¤ã®å¹³åã¬ãã«ã極ãã¦ä½ãã
ããã¾ã§è¦ãVBã¨ã³ã¸ãã¢ã®ã»ã¼å ¨å¡ã«å½ã¦ã¯ã¾ãç¹å¾´ã¯ä»¥ä¸ã®ãã®ãããã
- ä¸é·æçãªè¦éãæã¦ããç´ãã«ãã¨ã«ããåãã°ãããã ãã¨ãããã®å ´éãã®æé主義ã«èµ°ã
- ãè¯ãã³ã¼ããæ¸ããããæ°ãããã®ã使ãããã¨ããå¿åãæèãä¹ãããå¹¼ç¨ã§ç¨æã§æªçã§ç²éã§å漫ã§æ§æ ä¾ç¶ã®ã³ã¼ããæ¸ã
- ä»äºã«å¯¾ããã¢ããã¼ãå ¨ä½ãæ¦ãã¦åççã»éå¹ççãªãã®ã«ãªã£ã¦ãã
- ãã©ãããã¹ãããã¨ããæèãã§ããã åä¸æ欲ãæ¹é©æèã«èããæ¬ ãã¦ãããåºæ¬çã«ãç¾ç¶ç¶æããåé¡å éããã責任転å«ãã¨ããçµè«ãå ã«ãã
- æ®æ®µããããã°ã©ãã³ã°ã楽ããã§ããã¨ã¯å°åºæããªã
ä¾ãã°ãRubyããRubyãããæé«ã®ããã°ã©ãã³ã°è¨èªããRubyã¨ã³ã¸ãã¢ããã¨ã©ã«ãã¼ã®é ç¹ãã¨ã¾ã§ã¯è¨ããªãããã ãRubyã¨ã³ã¸ãã¢ã«ã¯ãè¯ãæ¸ãæ¹ã追æ±ããããã¨ããæèãé«ãã®ã¯æããã ãããããã¯åç´ãªã³ã¼ãã®ä½è£ã«ã¨ã©ã¾ãããRubyã®ã¨ã³ã·ã¹ãã å ¨ä½ã«ãããå¹ççãã¤åççãªã¢ããã¼ããã追æ±ãã¦ããåãããããã¾ãããã®çµå±ç¹ããRubyãæ¨ã¦ããã¨ããé¸æè¢ã«ãªããã¨ãæ£è¦ãããã®ã¯ç®èã ããRubyãæ¸ãã¦ããã¨ããããããæèé«ããç³»ã®äººéã®å¤ãã«æéãåããããããã«æåããã¦èªèº«ãæé·ãã¦ããã¯ãã ãã ããã¨ã³ã¸ãã¢äººçã®ä¸åº¦ã¯Ruby(ãããã¯ä»ã®æèé«ãè¨èª)ã«è§¦ãããã¨ã¯ééããªããã©ã¹ã«ãªãã¨æãã
VBã¯ãã®æ£å対ã ãVBã»ã©æèã®ä½ãè¨èªã¯åå¨ããªãããã¾ãã«æèãé«éããã®ãå°ãããä½ãããå ´åã¯ãã®æ¯ã§ã¯ãªããã¦ã¼ã¶ã¼å±¤ã®å¤§åããããã°ã©ãã³ã°åå¿è ã¾ãã¯ããã°ã©ãã³ã°ã¯å¥½ãã§ã¯ãªããä»äºã§ä»æ¹ãªããã£ã¦ããã ãã®ã¦ã¼ã¶ã¼ã§æ§æããã¦ããããæåãªVBã¨ã³ã¸ãã¢ããVBã§æ¸ãããæåãªã½ããã¦ã§ã¢ããªãã¦ã¨ã¦ãæãã¤ããªãããã«ãæ¬å½ã®å®åè ã¾ãã¯ä»è¨èªã§ã®çµé¨ãè±å¯ãªã¨ã³ã¸ãã¢ã®ä¸ã§ãå ¨ã¦ã®è¨èªã®ä¸ã§VBãä¸çªå¥½ãããªãã¦äººã¯ã»ã¼ããªãã ãããVBã¨ã¯ãããã°ãåºè¾ºãã ã
ãã ã§ããåãããã¸ã§ã¯ãã®ã¡ã³ãã¼ã«ã¹ãã«ãä½ã人éãè¦ãã¨æçµçã«ã¯è² æ ã«ãªãã¨ããã®ã«ãã¾ãã¦VBã¨ã³ã¸ãã¢ãæ§ç¯ããã·ã¹ãã ã®ä¿å®æ¡å¼µãè¡ãå ´åã¯çèã«å°½ãããããè¦çãè¦ãããå½¼ãã¯è¯ãã³ã¼ããæ¸ãè½åã«æ¬ ãã¦ããã ãã§ãªãããã¹ãæ¹æ³ããããã¤æ¹æ³ããªãªã¼ã¹æ¹æ³ããã®ä»ããããã«æ¼ãã¦ãè½åãããæ°ãç¥èããªãèªåéãç·¨ã¿åºããæéãæãããç¡é§ãå¤ããã©ãå¤å誰ã«ã§ãã§ããæ¹æ³ããè² ã®éºç£ã¨ãã¦æ®ãã¦ããã®ã§ãå¾ããæ¥ãæã ã¯ãã®ãããè¦å´ãããã¨ã«ãªãã
ã ããVBã«é·ã浸ããã°æµ¸ããã»ã©ããã®è ã¯ã¨ã³ã¸ãã¢ã¨ãã¦ã¯æªãæ¹åã«ããæé·ã§ããªãã¨ããè¦ç¬ãé³´ãããããåãã¦ã®è¨èªãVBã ã£ã人ã¯ãä»ãã®ç¬éãåãæµããã¦ããVBãªãã§ã¯ã®ããããã©ã¯ãã£ã¹ã»ã¢ã³ããã¿ã¼ã³ã«æåããã¦ãã¾ãããããæ®éã ã¨æãè¾¼ãã§ãã¾ããã¾ãVBçã®ã¨ã³ã¸ãã¢ããä»ã®ã¨ã³ã·ã¹ãã ã«æµå ¥ãããã¨ã¯ã害ãã«çãããè¨ãã°VB害ã (ãã£ã¨ãæµå ¥å ãJavaãPHPã§ããã°ããããã害ãåºãªãã®ã§ã¯ãªããã¨ã¯æãã)ã
å®éã®ç¾å ´ã§æ¸ãããã³ã¼ãã®è³ªãä½ãã
VBã¨ã³ã¸ãã¢ãæ¸ãå ¸åçãªãå¹¼ç¨ãªã³ã¼ããã®ãµã³ãã«ã示ãããã¨æãã®ã ããèªå¼µæãã§VBã®ç¾å ´ã§ã¯å®éã¯ããããæ´ã«å£®å¤§ãªã¯ã½ã大éã«ç²è£½æ¿«é ããã¦ããããããå®å ¨ã«ä¼ããããªããã¨ã¯æ®å¿µã§ããã
' ã¡ã½ããå: DoSomethingToDoWithDatabase ' æ¦è¦ã: åãåã£ãæååã«åºã¥ãã¦DBã«ã¢ã¯ã»ã¹ãã¦ä½ãã®å¦çããã¾ã ' å¼æ° : strParam åãåã£ããã©ã¡ã¼ã¿ã¼ ' æ»ãå¤: ãªã 'ãä½ææ¥: 2011/1/1 'ãä½æè : Taro Suzuki ' ä¿®æ£æ¥: 2014/12/23 ' ä¿®æ£è : Takeshi Tanaka (#366 No.3ã®å¦ç追å ) ' /------------- 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod start ' Public Sub doSomethingToDoWithDatabase(Byval strInParam As String, Public Sub doSomethingToDoWithDatabase(Byval strInParam As String, _ ByRef strOutMsg As String) ' 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod end ---------------/ Dim strProc1 As String = "1" ' /------------- 2014/10/20 #205 No.2ã®å¦çåé¤ Taro Yamada del start ' Dim strProc2 As String = "2" ' 2014/10/20 #205 No.2ã®å¦çåé¤ Taro Yamada del end ---------------/ ' /------------- 2014/12/23 #366 No.3ã®å¦ç追å Hanako Tanaka add start Dim strProc3 As String = "3" ' 2014/12/23 #366 No.3ã®å¦ç追å Hanako Tanaka add end ---------------/ ' /------------- 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod start strOutMsg = "" ' 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod end ---------------/ ' ãã©ã¡ã¼ã¿ã¼ã1ã®å ´å If strParam Is Not Nothing And strParam.equal(strProc1) Then Dim clsDbo As clsDataDbo = new ClsDbo("", Nothing, 1) Dim blnRet As Boolean = clsDbo.doSomething(strParam) ã' æ»ãå¤ãTrueã®å ´åã¯ããã·ã¼ã¸ã£ãæãã If blnRet = True Then ' /------------- 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod start Dim clsMsgFunc As ClsMsgFunc = New ClsMsgFunc(456, False) strOutMsg = clsMsgFunc.getMsg("doSomethingToDoWithDatabase", "Success") ' 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod end ---------------/ Exit Sub End If ' /------------- 2014/10/20 #205 No.2ã®å¦çåé¤ Taro Yamada del start '' ãã©ã¡ã¼ã¿ã¼ã2ã®å ´å ' Else If strParam Is Not Nothing And strParam.equal(strProc2) Then ' Dim clsDbo As clsDataDbo = new ClsDbo("", Nothing, 2) ' Dim blnRet As Boolean = clsDbo.doSomething(strParam) ' 'æ»ãå¤ãTrueã®å ´åã¯ããã·ã¼ã¸ã£ãæãã ' If blnRet = True Then ' ' /------------- 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod start ' Dim clsMsgFunc As ClsMsgFunc = New ClsMsgFunc(456, False) ' strOutMsg = clsMsgFunc.getMsg("doSomethingToDoWithDatabase", "Success") ' ' 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod end ---------------/ ' Exit Sub ' End If ' 2014/10/20 #205 No.2ã®å¦çåé¤ Taro Yamada del end ---------------/ ' /------------- 2014/12/23 #366 No.3ã®å¦ç追å Takeshi Tanaka add start ' ãã©ã¡ã¼ã¿ã¼ã1ã®å ´å Else If strParam Is Not Nothing And strParam.equal(strProc3) Then Dim clsDbo As clsDataDbo = new ClsDbo("", Nothing, 3) Dim blnRet As Boolean = clsDbo.doSomething(strParam) ã ' æ»ãå¤ãTrueã®å ´åã¯ããã·ã¼ã¸ã£ãæãã If blnRet = True Then ' /------------- 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod start Dim clsMsgFunc As ClsMsgFunc = New ClsMsgFunc(456, False) strOutMsg = clsMsgFunc.getMsg("doSomethingToDoWithDatabase", "Success") ' 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod end ---------------/ Exit Sub End If ' 2014/12/23 #366 No.3ã®å¦ç追å Takeshi Tanaka add end ---------------/ End If ' /------------- 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod start ' ã¡ãã»ã¼ã¸ããªãå ´åã¯ã¨ã©ã¼ã¡ãã»ã¼ã¸ãä»£å ¥ãã If strOutMsg Is Nothing Or strOutMsg.equal("") Then Dim clsMsgFunc As ClsMsgFunc = New ClsMsgFunc(456, False) ã strOutMsg = clsMsgFunc.getMsg("doSomethingToDoWithDatabase", "Error") End If ' 2011/12/31 #195 ã¡ãã»ã¼ã¸ã追å Hanako Tanaka mod end ---------------/ End Sub
è¡æ°ã®å²ã«ã¯å 容ã®èãã³ã¼ãã ãã³ã¼ãã®ä¸èº«ãããã³ã¡ã³ãã®æ¹ãè¡æ°ãå¤ãã縦ã«ã¹ã¯ãã¼ã«ããæéã¨å¦çã®å®æ ãé£ãåã£ã¦ããªãããã®ã³ã¡ã³ããã»ã¼100%ãä¸å¿ è¦ãªãã®ã§ãããä¸ã§ããå¯èªæ§ãæããããã³ããæã®ä¿®æ£æ¼ã(ä¸ã®ä¾ã«ãæ¢ãã¦å ¥ãã¦ããã)ãªã©ãå¼ãèµ·ããã¦çµæçã«ééã£ããã®ã«ãªã£ããã¨ãèªã人éãå©ããã©ãããããããã害ãã¨ãªã£ã¦ããã
ããä¸è¦ã«ãªã£ãã¯ãã®å¦çãæ®ããã¦ããã®ã¯ãVBãæ¡ç¨ããã¦ãããããªç¾å ´ã«ãããã¡ãªãæµåãã ãVBã®ç¾å ´ã§ãæµç³ã«ä»ã©ãGitã¨ã¾ã§ãããªãã¦ãSVNãæä½ã§ãVSS(ã¾ãããã®ã´ãã ã)ãããã¯å°å ¥ãã¦ããã¨ãããå¤ãã®ã ãããããã®è·å ´ã§ã¯ã½ã¼ã¹ã³ã¼ãã¯åºæ¬çã«åé¤ããã«ã³ã¡ã³ãã¢ã¦ãã§æ®ãã®ã§ããããã¼ã¸ã§ã³ç®¡çã½ããã®åå¨æ義ãåãè©°ããããããã ã
ã³ã¡ã³ãäºã ãæãã¦ããèå¿ã®ã³ã¼ããç¨æ極ã¾ããªãããªãã¸ã§ã¯ãæåäºã 以åã«æããã«æç¶ãåã®ã³ã¼ãã¨ãã¦ããæ´ç·´ããã¦ããªãããVBã®ç¾å ´ã«æ¼ãã¦ã¯ãDRYãæ½è±¡åã¨ãã£ãæ¦å¿µã¯åºæ¬çã«åå¨ããªãã¨è¦ã¦ããã
ãã¦ãããã§ãä¸ã«4çªç®ã®å¦çã追è¨ãã¦ãããã¨è¨ãããã¨ããã§ããªã人éã¯æããã¦ããã®ã ãããï¼éããã°ã©ãã¼ã©ãããå°å¦çã§ãå¯è½ã§ã¯ãªãã®ããã ãããããããã¯ã½ã³ã¼ãã«ã¯ãã¡ãªãããè¨ãã°ã誰ã§ãèªãããã¨ããå´é¢ãããããã«æãããããããããã§ã¯ä¾ç¤ºããããã«ç°¡ç´ ãªä¾ã示ããããå®åã®VBç¾å ´ã§ã¯ããããåé·ãªè¨è¿°ãè³ãæã«éè¤ãã¦æ£ãã°ãããã¦ãã¦ãããã調æ»è¿½è·¡ãã¦å¤ãã®ãã¡ã¤ã«ãä¿®æ£ã»ã»ã»ã¨ããã®ã¯éª¨ãæããããããã誰ã§ãèªãããã誰ããã£ã¦ãç²ãããã¨ããã®ãå®æ ã ãä½ã®æè¡åãè¦ããªãããã ã®è²¼ããããä½æ¥ã«çããã¬ãã«ã®ã³ã¼ãã£ã³ã°ãªã®ã ã
ãããæ²ãããã¨ã«ä½å質ã®è² ã®ã¹ãã¤ã©ã«ãVBã ãéå»ã«ä½ã£ãã·ã¹ãã ãä¿å®æ¡å¼µãã¦ããå ´åã¯ãã©ããã¦ãæ¢åã³ã¼ãã«å½±é¿ãåãã¦ãã¾ãã®ã§ãVBã§æ¸ãããä½å質ã®ã³ã¼ãããå®å ¨ã«è±å´ãããã¨ã¯ã§ããªããã©ããªåªç§ãªäººãåå ããã¨ãã¦ããå½¼/彼女ãæçµçã«ç£ã¿åºãVBã³ã¼ãã¯å¾ã ã«ãã¦ä»ã¨å¤§å·®ãªããã¨ãå¤ããã¯ã½ã³ã¼ãéãã¦ãªãã¡ã¯ã¿ãªã³ã°ãªãããã¦ãã¾ã£ãããçæéã§å¥ç´æ´æ°ãããæ¾åºããã¦ãã¾ãå¯è½æ§ããããã
ä½æ ãªããæ¦ãã¦ãªãã¡ã¯ã¿ãªã³ã°ã¨ããã®ã¯ããã«è¦ããæéã¨ãã°ã¬ãçºçãã¦ãªããæ ä¿ããæéãèããã°ãé常ã«å²ãåããªããè³¢æãªã¨ã³ã¸ãã¢ã¯ããã»ã©ã®å¤§å¹ æ¹ä¿®ããªãéãã¯ãããããéå»ã®ä½å質ã³ã¼ããæ¸ãç´ããããªãã¨ã¯ããªããããã¯æ¥æ¬ã ãã§ãªãä¸çå ±éã®ççã ãä¾ãã°GitHubã§ããè£ é£¾çãªå¤æ´ã ãã§ãªãåãªããªãã¡ã¯ã¿ãªã³ã°ã¯ããªã¼ãã¼ãã³ã©ãã¬ã¼ã¿ã¼ä»¥å¤ãããã«ãªã¯ã¨ã¹ããããå ´åããªã¹ã¯åé¿ã¨ãã§ãã¯ããæéããã¯ãã¼ãºããããã¨ãå°ãªããªãã
ã¾ãã¦ãVBãæ¡ç¨ããç¾å ´ããªãã¡ã¯ã¿ãªã³ã°ã®å·¥æ°ãªãããè¦ç©ããã¯ãããªãããæªã ã«èªååãããåä½ãã¹ããå°å ¥ãã¦ããªãç¾å ´ãå§åç大å¤æ°ãªã®ã§ããªãã¡ã¯ã¿ãªã³ã°ã«ãããã°ã¬ã¼ã·ã§ã³ã®ãªã¹ã¯ã¯æ¥µãã¦é«ããVBã§æ¸ãããã½ã¼ã¹ã³ã¼ãã®ã»ã¼å ¨ã¦ãç¨æã§åé·ã§ãã ã®è² åµã«ãªã£ã¦ããã®ã¯ãçµå±ã¯ãè¯ãã³ã¼ããæ¸ããã¨ããæèãVBã¨ã³ã¸ãã¢ã«ã¯èããã¾ãæåçã«è¯ãã³ã¼ããç£ã¿åºãã«ããã¨ããå´é¢ãããããã ã
ä¸ã«ã¯ãããããªã³ã¼ããæ¸ããããã¨ããã®ã¯ããåã®ç¬ãåãããªä¾¡å¤è¦³ã«éããªãã ãããã¨è¨ãæè¦ãåºãã ããããæããã¦ããã ãããã極è«ãè¨ããªãã°ãå ¨ã¦ã®ããã°ã©ãã³ã°è¨èªã¯ãã·ã³èª(0ã1)ã®ã·ã³ã¿ãã¯ã¹ã·ã¥ã¬ã¼ã§ãããããããå¦ä½ã«ç¾ããã綺éºã«ãç°¡æ½ã«æ¸ããããã¨ããå½é¡ã社ä¼ã追æ±ãã¦ãã£ãçµæãCè¨èªã§ã¯é£½ã足ãããããã©ã¼ãã³ã¹ãç ç²ã«ãã¦ã¾ã§ããããé«ç´è¨èªã2014å¹´ã®ä»æ¥ãæªã åèãã¦ããã®ãç¾å®ã§ã¯ãªãã®ãã
ããããããçãæ¸ãããããããç¾ããã³ã¼ããæ¸ãããããããè¯ãã³ã¼ããæ¸ããããã¨ããæ°æã¡ã¯ãæ¬æ¥ã¯ããã°ã©ãã¼ã®æ¬æºçãªæ¬²æ±ã§ããããããããéã«ããã°ã©ãã¼ãæé·ããã¦ãã糧ã¨ããæãããããããå¿åãèãã¨ã³ã¸ãã¢ã¯ãããã°ã©ãã¼ã¨ããããã¯ãITä½æ¥å¡ã¨ãITåæ¹ã¨ç§°ããã«è¿ãã
ããããããªã³ã¼ãã£ã³ã°ã¨ã¯å¼ã³é£ãåç´ä½æ¥ãé·æã§ãã£ã¦ããã人ã¯ã©ããªãã ããããã»ã©ä»ã®ç¾å ´ã§è¯ãã³ã¼ããè¦æ £ãã¦ãã審ç¾ç¼ããã人éãªãã¨ããããçµé¨ã®æµ ã人ããã®é¡ã®ã³ã¼ããæ¯æ¥è¦ã¦ããããããã°ã©ãã³ã°ã¨ã¯ãããªãã®ãã¨ãã誤ã£ãåéããèµ·ãããããªããããã®å¾ã®ãã£ãªã¢ã«ééããªãæªå½±é¿ãåºãã ããã
ã人æããããã®ç¨¼åå売ã¨æ¥µãã¦ç¸æ§ãè¯ããã¯ã½ã³ã¼ããå©é·ããã社ä¼æå§ãããã
VBã¨C#ã®å·®ã«ã¤ãã¦ã¯ãæµ·å¤ã§ãå½ç¶ã®ããã«è©±é¡ã«ãªãããVBããã®ãã¼åãã®è¨èªã§C#ããæ©è½ãå°ãªãã¨ããåè¦ã¯ããããç¹ã«ã¦ã¼ã¶ã¼ã®ã¬ãã«å·®ãææãã声ã¯å ¨ãè¦ãªããã§ããã°ãæ¥æ¬ç¤¾ä¼ã®éæªãã¨ITæ¥çã®è² ã®å´é¢ã®ãã¤ããªãããVBãé§ç®ã«ããã®ã§ã¯ã¨ããæ¨å®ãã§ãããæ´ã«è¨ãã¨ãVBããæ¥æ¬ã®ITã®é§ç®ããç©èªããã®ã§ã¯ãªãã®ããæ¥æ¬ã®ITã®è² ã¨ã¯ãè¨ãã¾ã§ããªãSIerã¨ããã«ç¾¤ããç¡æ°ã®äººå£²ãå売ã®é¶ç´°ä¼æ¥ã®ãã¨ã§ããã
ç¦å³¶ç¬¬ä¸åçºäºæ ã¨ããä¸çãã注è¦ããã¦ããç¾å ´ã§ãããå¤éæ´¾é£ãå½è£ è«è² ã横è¡ããéé ·ãªä½æ¥ãå¼ãåããä½æ¥å¡ãåãåãæ£å½ãªå¯¾ä¾¡(ãããå½æ°ã®ç¨éãæºæ³ã¨ãã¦ãã)ããã³ãããããã¨ã«èºèºããªãã®ãæ¥æ¬äººã ãITæ¥çãåæ§ã§ãä»æ¥ãã¾ãå¤æ°ã®ITæè¡è (ã¨ã¯åã°ããã®åæ¹)ãç¾å ´ã«æ´¾é£ããã¦ããããã³ããããå´ã®æã潤ããå¹³åå¹´é½¢ã50æ³ã«è¿ãæ¥æ¬ã§ã¯ã極å°æ°ã®äººéã®æ¢å¾æçãå®å ¨ã«çæããã¦ããããããç¶æãããããã«ã³ã³ããã¼ã«ããã¦ããã®ã ã
ããããSIerã管çããç¾å ´ã§ã¯ãã¢ããã®ææã¨ãå質ã§ã¯ãªããã人æããããã§æç®ããå·¥æ°ã§éãæãããã ãããå½ç¶éãåºãå´ã¯ãå¦ä½ã«å¤ãã®äººãéãè¾¼ã¿ãå¦ä½ã«å·¥æ°ãå¢ããã¦ãå¦ä½ã«å®¢ã«ããã飲ã¾ãã¦è«æ±ããããã«å·çããªãã¨ãããªãããä½ãä½ã£ããããã©ãã ãè²¢ç®ããããã¨ããç´ç²ãªæè¡ã¨æ³ååãåãã®ã§ã¯ãªãã¦ããã©ãã ãç¾å ´ã«ããããã¨ãã稼åã«å¯¾ãã¦å¯¾ä¾¡ãè²°ãããã§ãæä½éã®ç¥èã¨ãã¸ãã¹ããã¼ããæã£ã¦ããã°ã¾ãã«èª°ã§ãããã£ã¦æãã«ãªã£ã¦ããããããæè¡åãé¢ä¿ãªããããããç°æ§ã«ãã¸ãã¹ããã¨ãã§æã足ãåãSIerãå¤ãã
VBã¯B2Bã»B2Gã®ç¾å ´ã§æ¡ç¨ãå¤ããã¨ãè² ã®å¾åã«æè»ãããããä½ããã硬ã大ä¼æ¥ãå®å ¬åºã顧客ã ã£ãããå è«ãæ¥ç«ã»å¯å£«éã»NTTã¨ãã®è¶ 大ä¼æ¥ã ãããã¨ã«ããå½¢å¼ä¸»ç¾©ã¨ä¿å®ä¸»ç¾©ãããè³ä¸ã¨ãããããä½ãæ£ãããããä½ãåççããã¨ããè¦è§£ã¯é»æ®ºããã¦ãä»ã¾ã§ã©ãã ã£ããããæãå¼·ãæå³ãæã¤ãæ¢å¾æçãåãåºã¾ã£ã¦ãä¸æã«æ´å²ãããããããéå»ã®å¤§ãããã¨ãªãå®ç¸¾ãé度ã«ç²ä¿¡ããèªåãã¡ã®ç«ã¡ä½ç½®ãå®åãå¼ããã©ãããããããèªåãã¡ã¯åªãã人éã§ããã¨ããåéããã奴ãããã
ã¨ãªãã°ãåé·æ§ã¨ã¹ãããæ°ã競ãåãããã«ã¯ã½ã³ã¼ããæãæ£ãããå¯èªæ§ãä¸ãã¦ãä¿å®æ§ãä¸ãã¦ãå°æ¥ã®ã¡ãã£ã¨ããã¡ã³ããã³ã¹ã®è¦å´ãåå¢ããããã¨ã¯ãå·¥æ°ã¨äººå¡ãå¢ããã¨ãã観ç¹ããã¯çã«é©ã£ã¦ãããå°ãã³ã¼ããæ¸ãã¨ãªã£ãããåãå 容ãã½ã¼ã¹å ã®ã³ã¡ã³ãã©ããããã¼ã¸ã§ã³ç®¡çã½ãããå¤æ°ã®ã¨ã¯ã»ã«æ¹ç¼ç´ã«æ¸ãã¦ãä¸ã®äººéã«ã¬ãã¥ã¼ãã¦èª¤åã®ä¸ã¤ã許ããªãã»ã©ã®å¢ãã§è¦ã¦è²°ãã¨ãããä¸è¦ã½ããã¦ã§ã¢éçºã«ããã¦æ¥µãã¦éå¹ççãªã¢ããã¼ããåæ§ã«ã¾ãå°¤ãé«ã売ä¸ãç£ãã顧客ããããçç ´ã§ããªããã°ããã®1å1ç§ã«å¯¾ä¾¡ã渡ãã®ã ããã
VBã®ç¾å ´ã¯ãåºæ¬çã«ã人海æ¦è¡ãã«ä¾åããç®è¦ã«ãã確èªãæåã«ä¾ãä½æ¥ã®åº¦åããå¼·ãä½æ¥è ã®è² æ ã¨ãªããããªéå¹ççãªåç´ä½æ¥ã®éãé常ã«å¤ãããã®çç±ã¯â¡ã§è¿°ã¹ãããã«VBã¨ã³ã¸ãã¢ã¯æè¡åãæ欲ãä½ãã®ã§å¹ççã»åççãªææ³ã®å°å ¥ãåºæ¥ãªãã®ã大ããªçç±ã§ãããã第ä¸ã«éå¹ççãªææ³ãæ¯æ£ãããç°å¢ã§ã¯ãªãã®ãæ大ã®çç±ã§ããã
ããããããã³ããä¼æ¥ã«ã¨ã£ã¦ãã綺éºã«ã»çãã»èªã¿æãã»ç¾ããã»ç°¡æ½ã«ãã³ã¼ããæ¸ããã¦ãã¾ãã®ã¯å¡ãèä¿¡è¡çºã«çããã®ã ãä»®ã«ä¸é¨ã®åªç§ãªã¨ã³ã¸ãã¢ãéã¾ã£ã¦ãé«ãéçºå¹çã§ãããå°ãªã人æ°ã¨ããå°ãªãæéã§ã½ããã¦ã§ã¢ãä½æããä½ã³ã¹ãã«ããéç¨ã¨ä¿å®ä½å¶ãç¯ãä¸ããã¨ããããããã¯ãåä¾ãã¨ãªã£ã¦ãã¾ãã顧客ãä»å¾ã®æ¡ä»¶ãçºæ³¨ããéã®åºæºã«ãªã£ã¦ãã¾ããåªç§ãªã¨ã³ã¸ãã¢ãæ¸ãã³ã¼ãã¯ãæ¬äººéã¯ãæ¢ãã¦é£ãããã¨ã¯ãã¦ãªããã¤ããã§ããæ°ãç®ã®ã·ã³ã¿ãã¯ã¹ãAPIã使ããã¦ãã¾ãã¨ãã©ããã¦ãä¸åå¼·ãªã¨ã³ã¸ãã¢ã«ã¯èªã¿ã«ãããåªç§ãªã¨ã³ã¸ãã¢ã¨ããã®ã¯æ°ã¨ãã¦ç¸å¯¾çã«å°ãªããã®ã ãã給ä¸ãé«ããªããããè¤æ°ã®ä¼ç¤¾ããã³ããããå ã®éé¡ã®åå以ä¸(æã«ã¯1/5)ã¨ãªã£ãå ±é ¬ã§å¼ãåãã¦ããããã¨ã¯ãªããã ãã飽ãã¾ã§ãå·¥æ°ã®åºæºã¯ããã³ããä¼æ¥ãä½åå¹´ãæãã¦æ¢æäºå®ã¨ãã¦æ°´å¢ããããä½å ±é ¬ã§ITæ¥çæªçµé¨ã®äººéãä½ã¹ãã«ã®äººéãããéãã¦ãä½ããã´ãã®ç£ç©ã®ãç·æéããç·ã¹ãããæ°ãã§ããã¹ããªã®ã ã
ããããè·å ´ã§ã¯ãé ·ãã¨ãã¯ã³ã¼ãã®å質ãå°æ¥ã®ä¿å®æ§ããããã¹ãããæ°(è¡æ°)ã§äººã®çç£æ§ã管çãã¦ãããä¾ãã°ã1æéããã¦ãããã®å ¨ãã¡ã¤ã«ã«ã³ãããã¦æ¸ãè¾¼ãã§å¤§éã®ã³ã¼ããçç£ããæ¹ãã1æ¥ããã¦èª¿æ»ãã¦è¨å®ãã¡ã¤ã«ã«ä¸è¡è¿½å ãããã¨ã§è§£æ±ºãããããåªãããã¨ãªã®ã ãå°æ¥ããã®å¤§éã®ã³ããã®ä¸ã¤ä¸ã¤ãèªãã§ä¿®æ£ãããã¨ãæ³èµ·ã§ããªãè¿è¦ç¼çãªè¦éããæããªãããã¡ããVBã®ç¾å ´ã¯å¿ ãã¨ã¯ã»ã«æ¹ç¼ç´ã®å±±ã ã¨ã»ããã ãã©ãã³ã¼ããå°ãç´ãã ãã§ã¨ã¯ã»ã«æ¹ç¼ç´ã大éã«ä¿®æ£ããªãã¨ãããªãããããããã®ã·ã¼ãæ°ãèªãã«æããããªæåãã°ããã ã
ä½æ VBã§æ¸ããã¦ãã³ã¼ãã¯ã»ã¼å ¨ã¦ã¯ã½ãªã®ããä½æ VBãæ¡ç¨ãã¦ããç¾å ´ã¯ã»ã¼å ¨ã¦ã¯ã½ãªã®ãããã®çµå±çãªã®çç±ã¯ããã«å°½ããã誰ã§ãããããã¯ã½ãåãæµãã¦ä¸å®æéå¸ã«åº§ã£ã¦ããã°éãè²°ããã®ã ãã¯ã½ãåãæµãã®ã¯æ¥½ã ãç°¡åã ãè¿ éã ãããã°ã©ãã¼ã§ãªãã¦ãã§ãããæ¢ã«ã¯ã½ãããã°ãéãè²°ããã¨ããä½å¶ã確ç«ãã¦ããã®ã ãããã¯ã½ä»¥å¤ã®ç£ç©ãä½ããã¨ã¯ãªãããéã«ã¯ã½ä»¥å¤ãä½ãããããããªäººéã¯æ©æã«éå ´ããã¦ãããªãã¨ãããªãããä¿å®æ§åä¸ããèªååããå°æ°ç²¾éãã»ã»ã»ãããã¯ã¿ããªã¿ãã¼ã«çãããã誰ã§ãã§ããä»äºãã誰ã§ãæéã¨æéã®ãããä»äºããæåã¨ç®è¦ã§ä¸¸ä¸æ¥æ å½ããã¦ã顧客ããéãå·»ãä¸ããéã«ãVBã¨ããè¨èªã¯é常ã«çã«é©ã£ã¦ããã®ã ã
âããããããã£ã¨è¨èªã®ä»æ§çãªè©±ã«ãªãã
å°ãªãã¨ãVB2010ãããã¾ã§ã¯C#ã¨å¤§å·®ããã£ãã
ä»ã§ã¯ã»ã¨ãã©å·®ã¯ãªããªã£ã¦ããããC#ã¨VBã¯ãã¨ã¯å¥è¨èªã ã£ããã ãããC#ã«ã¯ãªãã¦VBã«ã¯ãããã¾ãã¯ãVBã«ã¯ãªãã¦C#ã«ã¯ãããã¨ããäºãã¶ã©ã§ããããå ¨ä½çã«ã©ããVBã®æ¹ãé ãæ°å³ã§ãããæ¯è¼ç大ããã®æ©è½ã§VBãé ãã¦å°å ¥ãããã®ãä¸ããã¨ãããªæãã«ãªãã
VB.NETã®å°å ¥ææ | æ©è½ | C#ã®å°å ¥ææ |
2005 | æ¼ç®åãªã¼ãã¼ãã¼ã | 2001 |
失ææã«ä¾å¤ã§ãªãNullãè¿ããã£ã¹ãæ¼ç®å | 2001 | |
continue | 2001 | |
using | 2001 | |
åç §åã®éçå·æ¼ç®å | 2001 | |
ã¡ã½ããã®XMLã³ã¡ã³ã | 2001 | |
符åãªãæ°å¤å | 2001 | |
2008 | Null許容åã®ã·ã³ã¿ãã¯ã¹ã·ã¥ã¬ã¼ | 2003 |
ä¸é æ¼ç®å | 2001 | |
2010 | æé»ã®è¡é£çµ | 2001 |
yield | 2005 | |
è¤æ°è¡ã©ã ãå¼ | 2008 | |
Actionåã®ã©ã ãå¼ | 2008 | |
èªåå®è£ ãããã㣠| 2008 | |
ã³ã¬ã¯ã·ã§ã³åæåå | 2008 | |
é ååæåã·ã³ã¿ãã¯ã¹ã·ã¥ã¬ã¼ | 2008 |
å人çã«ã¯ãVBã®ã³ã¼ãã®ç¾è¦³ãå§åçã«æãã¦ããæ¹è¡ã®_
ãä¸è¦ã«ãªãã®ã2010å¹´ã¨å²ã¨é
ãããã®ãè´å½çã ã£ãã¨æãããã®ã¨ã³ããªã¼ã§ãããã¨æ¹è¡ãä¸èªç±ã ã£ãã¨ãã®ã³ã³ãã¤ã©ãåæã«ã³ã¼ãä¾ãåºãã¦ããé¨åãããã
ãã¡ãããC#ã ã£ã¦å¤§ããã¨ããã§ã¯2010å¹´ã¾ã§ãªãã·ã§ã³å¼æ°ã¨ãååã¤ãå¼æ°ããªãã£ãããã¨è¨ã人ãããã ãããããããå®ã®ã¨ããæ©è½ã®å®è£ é ãã¯C#ãããVBã®æ¹ãé¥ãã«æ·±å»ã§å½±é¿åã®ããã¨è¨ããããå¾ãªããã¨ããã®ãããã ã§ãããã¼ã¸ã§ã³ã¢ããã«ã¯ãªã¹ã¯ãããã®ã§ããã¸ã§ã¯ãã大è¦æ¨¡ã§ããã»ã©å¿é¿ãããå¾åã«ããããç¹ã«VBã使ãç¾å ´ã¯äºãªãã主義çãªã®ã§äºææ§ã®æ¯è¼çé«ã.NETã§ãã£ã¦ããã¼ã¸ã§ã³ã¢ãããªãã¦ããªããããã¯æè¨ãã¦ããããä»®ã«ãã¼ã¸ã§ã³ã¢ãããããã¨ãã¦ä¸ã«è¿°ã¹ãããã«VBã¨ã³ã¸ãã¢ã¯å ¨ä½çã«ã¹ãã«ãä½ããããã°ã©ãã³ã°ã®åå¼·ãæ ãã©ãããããããããã°ã©ãã³ã°ã好ãã§ã¯ãªãä»äºã®ããã«ä»æ¹ãªããã£ã¦ããã ããªã®ã§ãé常ã¯éå»ã®ã³ã¼ããã³ãããã¦ã¡ãã£ã¨å¤ããã ãã§ããã追å ãããæ°APIãæ°ã·ã³ã¿ãã¯ã¹ãªãã¦ä½¿ãã¯ãããªãã
ç価æ¼ç®åã¨ä»£å ¥æ¼ç®åãåãã
ããã°ã©ãã³ã°ãå§ããåæã¯ã==
ãã«æ°æã¡æªããã®ãæãããPascalãDelphiã®ã:=
ãããã¾ã好ã¿ã§ã¯ãªãããããã代å
¥ç¨ã«ããããããããæ°æã¡æªãæ¼ç®åãæ¡ç¨ãããã®ãçç±ããããã¨ããã®ããVBã®ããã«ç価æ¼ç®åã¨ä»£å
¥æ¼ç®åãæèä¾åã ã¨ä¸é½åããããèéãå©ããªãã®ã ã
ä¾ãã°ãVBã¯å¤éä»£å ¥ãã§ããªããä¸ã®ãããªå®å ¨ã«åä¸ã®ã³ã¼ãã§ãC#ã¨VB#ã§ã¯çµæãç°ãªãã
// xã¨yã«0ãä»£å ¥ããã x = y = 0;
' xã«(y=0)ã®æ¯è¼çµæãä»£å ¥ããã x = y = 0
æãããVBã®ã³ã³ãã¤ã©ã¯æã¨å¤æããªãã¨ã³ã³ãã¤ã«ãéããªãã¨ãã¯=
ã¯ä»£å
¥ã¨è¦ãªããå¼ã¨å¤æã§ããã¨ãã¯=
ãæ¯è¼ã¨è§£éãã¦ããæãããã
ã¤ã³ã¯ãªã¡ã³ãã¨ãã¯ãªã¡ã³ãããªã
ã¤ã³ã¯ãªã¡ã³ãã»ãã¯ãªã¡ã³ãããªãè¨èªã¯æå¤ã«å¤ãã主è¦ãªè¨èªã§ãPythonãRubyãScalaãLuaã¯åãã¦ãªããçç±ã¯è¤æ°ããããã ãããªãã¸ã§ã¯ãæåè¨èªã ã¨ãæ°å¤åã§ãã£ã¦ã++
ã¯ã¹ã¿ãã¯é åã®å¤ãã¤ã³ã¯ãªã¡ã³ãããã®ã§ãªãããã¼ãé åãæãã¦ãã¢ãã¬ã¹ã®å¤ãã¤ã³ã¯ãªã¡ã³ããã¦ãã¾ããã¨ã«ãªããããã¨ãã説ãããããªãä¸å¿ã¯æ°å¤åãå«ãå
¨ã¦ããªãã¸ã§ã¯ãã¨ããè¨è¨ææ³ã®VBã«ããã¦ã¤ã³ã¯ãªã¡ã³ãã»ãã¯ãªã¡ã³ããç¡ãã¦ãåé¡ã¯ãªãã»ã»ã»ã¨è¨ãããã®ã ããC#ã«ã¯ã¡ããã¨ããã®ã§ãããã«æ¯ã¹ããVBã¯ãã¯ãé§ç®ã¨ãããã¨ã«ãªãã
ãã¡ãã+=
ã使ãã°ãæ(ã¹ãã¼ãã¡ã³ã)ã§ããéãã¯åãæåæ°ã§åãäºã¯ã§ããã®ã§ã代å
¥ãããã ããªãããã¾ã§å·®ã¯ã§ãªãã
i++; i--;
i+=1 i-=1
ä½ãC#ã¯ã¡ã½ããã®å¼æ°ã«ãã®ã¾ã¾å¢æ¸ãããè©ä¾¡å¤ãè¿ãã(ã¤ã¾ããå¼ã¨ãã¦å©ç¨ã§ããã)ãVBã«ã¯ä»£å ¥ã¨ã¡ã½ããå¼ã³åºãã¨ãããæããæãã®çµã¿åããã«ãªãã®ã§ã2è¡ã«ãããããªãã
obj.doSomething(++i);
i-=1 obj.doSomething(i)
ByValãçç¥ã§ããªãã£ãããOptionalã¯ãã¾ã çåã§ããªãã
é¢æ°ã®å¼æ°ãå®ç¾©ããã¨ããVBã¯å¸¸ã«ByVal
ãByRef
ã®ããããã®æ示çãªæå®ãå¿
è¦ã ã£ãã
void DoSomething(int i) { }
Sub Something(ByVal i As Integer) End Sub
ä»®ã«ByVal
ãçç¥ãã¦æ¸ãããããããããæ¶ããã¨ããã常ã«VSãå¼·å¶çã«è£å®ããããã¤ã¯ãã½ããã®ãµã¤ãã«ããã¤ã¦ã¯ãçç¥ãã¦æ¸ããªããã¨ããå§ããã¾ããã¿ãããªæ ¹æ ãä¸æãªã¢ããã¤ã¹ããã£ããããããçç¥ãããæé»ã§å¤æ¸¡ãã«ãããï¼ãã¨å¸¸ã
æã£ã¦ããããMSããã£ã¨éãè
°ãä¸ãã¦VS2010以éã¯çç¥å¯è½ã«ãã¦å½è©²æè¨ããµã¤ãããæ¶ããããããããé
ãããæ°ãããã
å ãã¦ãVBã¯ãªãã·ã§ã³å¼æ°ãã®ãã®ã¯C#ããããªãæ©ã段éã§å°å
¥ãã¦ããã®ã ãããã®ä»£ããOptional
ã常ã«å¼æ°ã®å®ç¾©ã«ä»ä¸ãå¿
é ãè¤æ°ã®ãªãã·ã§ã³å¼æ°ãããã¨ããããå
¨ã¦ã®é ã«Optional
ãè¨è¿°ããå¿
è¦ãããããããçç¥ãããã³ã³ãã¤ã«ãéããªãã¨ããã®ã«VSã¯ã¨ã©ã¼ãåºãã ãã§èªåè£å®ãããªãã
ãã®çµæãC#ã¨VBã®ã¡ã½ããå®ç¾©ã¯æ²ãããªããããèªã¿ãããã«å·®ãããã
void DoSomething(int i, int j = 0, int k = 1, int l = 2, int m = 3, int o = 4) { }
Sub DoSomething(ByVal i As Integer, ByVal Optional j As Integer = 0, _ ByVal Optional k As Integer = 1, ByVal Optional l As Integer = 2, _ ByVal Optional k As Integer = 3, ByVal Optional l As Integer = 4) End Sub
ãã¡ãã2010以éã¯ByVal
ã¨æ¹è¡ã®_
ãä¸è¦ã«ãªã£ãããä»ã¯ã ãã¶ãã·ã«ãªã£ãã¨è¨ããã®ã ãããããVBã®åé·æ§ãå©é·ããè¨èªã¨ããè©ä¾¡ã示ã大ããªä¸ä¾ã ããªãããªãã·ã§ã³å¼æ°ã«ã¤ãã¦ã¯ä¸ã§ã軽ã触ãã¦ããããä»ã«ãä¸å¯è§£ãªä»æ§ãããã
AndãOrã常ã«å³è¾ºãè©ä¾¡ãã
VBã®And
ãOr
ã¯ä»è¨èªã«ããã&&
ã||
ã¨ã¯éããã¨ããã®ããVBã®å ´åã¯ãã¨ãè©ä¾¡ä¸ã«å·¦è¾ºãfalse
ã«ãªã£ã¦ã常ã«å³è¾ºãè©ä¾¡ãããIfæã®æ¡ä»¶å¼ã10åãããè¤åããã¦ãã¨ããã(ã¬ããªè©±VBã«ã¯ãããã)ãæåã®1ã¤ãçã ã£ãã¨ãã¦ãæ®ãã®9åãæå¾ã¾ã§ç¶ãããããã«ãããä¸å¿
è¦ãªã¬ãã½(ã¬ãã)ãã§ãã¯ãããã©ã¼ãã³ã¹ã®æªåãæã(ãã¡ããå³è¾ºã®è©ä¾¡ã«ã¯ããªç§ãæãããªããã¨ã大æµã ããã)ã
if (obj != null && obj.Count > 0) { }
If (obj Is Not Nothing And obj.Count > 0) Then End
ããããã空ã®ã³ã¬ã¯ã·ã§ã³ãè¿ããªãï¼ãã¨è¨ãããããªãä¾ã ããä¸è¨ã®å ´åã¯VBã ãã¬ãã½(å³å¯ã«è¨ãã¨ã¬ããã ãããã®ã¨ã³ããªã¼ã§ã¯ä»¥éNull Reference Exceptionãã¬ãã½ã¨å¼ç§°ãã)ãçºçãããæµç³ã«ãããã§ã¯é§ç®ã ããã¨ãã¤ã¯ãã½ãããèªè¦ããã¦ããã®ã§ã左辺ãé§ç®ã ã£ããéä¸ã§åãä¸ããAndAlso
ãOrElse
æ¼ç®åãç¨æããã¦ããããããããã ã§ããé·ãã®ã«4æåé·ããªãããããããVBã¨ã³ã¸ãã¢ã¯æè¡ãç¥èãä¹ããã®ã§ãã¾ã使ããã¦ããªãã®ãå®æ
ãAndAlso
ã¨And
ã®éããç¥ããªãã¨ããããèå³ãªããã ã¨æããåãã°ãããã ãã
åçåã¥ããæ¡ç¨ããå ´åã®ç²åº¦ã大ãããã
VBã«ã¯ãã£ã¦C#ã«ã¯ãªãã£ãè¦ç´ ã®ä»£è¡¨çãªãã®ã¨ãã¦åçãã¤ã³ãã£ã³ã°ãããããC#4.0ã§ã¯éã«dynamic
ãå°å
¥ããããã¨ãããC#ã®å ´åã¯å±æçã«dynamic
ãç¨ãããã©ããé¸æã§ããã®ã«ãVBã®å ´åã¯å°ãªãã¨ããã¡ã¤ã«åä½ã«ãªã£ã¦ãã¾ããåçåãç¨ããå ´åã®å½±é¿ç¯å²ã¯æå°éã«ãããã®ã«ãããã¯é常ã«å°ãä»æ§ã§ããã
void DoSomething(dynamic x, Object y) { x.Hoge(); y.Fuga(); // ã³ã³ãã¤ã©ãæã }
Option Strict Off Sub DoSomething(ByVal x, ByVal y As Object) x.Hoge y.Fuga ' xãyã両æ¹ã¨ãObjectæ±ãã§ããªããã¤ã³ã³ãã¤ã©ãè¦åãåºããªã End Sub
ããããå¼·ãéçåä»ãè¨èªã®C#/VBã§æ¢ãã¦åçåã使ãå±é¢ã¯ãã¾ãå¤ããªãã¯ãã ããåå¿è
ã»ã©Visual Studioã®ç§é¸ãªè£å®æ©è½ã«é ¼ããåä»ãæ©è½ãå©ç¨ããæ¹ãããã¨æãã®ã ããVBã«ã¯Option Strict Off
ãæ¡ç¨ããææ³ãæ ¹å¼·ããåçè¨èª(Rubyã»JavaScriptãªã©)ã®æç¨è
ã¨ãã¦ãåçåã®ã¡ãªããã¯å°åºå¦å®ã§ããªãããVBã®å ´åã¯ãåã¨ãããããããªãããããå æ¸ã§ãåãã°ãããã ãç¨åº¦ã®çç±ã§åã¥ããç¡ããããããã«è¦ããã
ãªãã俺ã®è·å ´ã«ãVBã®ããã«ãã£ã¡ãã¾ãã«ã³ã¼ãè¦ç´ãªãã¦ãã®ããããä½ãä½ã度ã«ã¨ã¯ã»ã«æ¹ç¼ç´ã«é
ç®å¥ã«ãã§ãã¯ããªãã¨ãããªãã(ãã«ãããã®ã§éä¸ãããããªããªã£ã)ããã®ä¸ã«ãæé»ã®åå¤æã¯ä½¿ç¨ããªããã¨ãã¨ãæ¸ãã¦æããããããæåããã½ãªã¥ã¼ã·ã§ã³ã¬ãã«ã§ç¦æ¢ãããï¼ãã¨ãæãã®ã ããããã¦ããã¡ã¤ã«åé ã«Option Strict On
ã¨æ¸ããã¨ããããã®è¨è¼ã«ãã¦æ¬²ããã¨æã£ããè¨å®ãããè¦ç´ããã人ç¼ã«ãã管çãæ¯ã¨ããVBã¨ã³ã¸ãã¢ãããã¨ãã½ã¼ãã ã
大æåå°æåãåºå¥ããªã
VSã§å ¥åããªãã®ã§ããã°ãåºå¥ããªã(ã¤ã³ã»ã³ã·ãã£ã)ãªã®ã«ã¯æ£ç´ç¡è¦ã§ããªãå©ç¹ããããShiftãã¼ãæããªãã¦æ¸ãã¨ãCaps Lockã®ã¾ã¾æã£ã¦ãæ¢ã«ã¿ã¤ããããã£ãã¿ã¤ã©ã¼ã¼ã·ã§ã³ã«æ»ãã¦ããããã楽ã¨ãã«å ãã¦ãå ¨ã¦ã®ããã°ã©ãã¼ã«ã¨ã£ã¦èµ·ãããããç¹ã«åçè¨èªã§ã¯æ¤åºãã«ãã大æåã¨å°æåã®æã¡ééãã®ãã¹ããªãã¦æ¸ãã
ãã ãVSã§ããã°è£å®ãã¦ãããããæã¡ééãã®ãªã¹ã¯ã¯æ¸ãããä¸æ¹ã§ãããããã£ã¨ãã®å¤ãä¿æããã¡ã³ãã¼å¤æ°ã®å½åãããåä»ã«ãªãã®ã§_
ã¨ãm
ã¨ãã¡ã³ãã¼å¤æ°ã«ã¯ã¤ãããããå¿
è¦ãããã
class Hoge { private int foo; private string bar; Hoge(int foo, string bar) { this.foo = foo; this.bar = bar; } int Foo { set{this.foo = value;} get{return this.foo;} } }
Class Hoge Private _foo As Integer Private _bar As String Sub New(ByVal foo As Integer, ByVal bar As String) _foo = foo _bar = bar End Property Foo As Integer Get Return _foo End Get Set(ByVal value As Integer) _foo = value End Set End Property End Class
å人çã«ã¯C#ã®æ¹ã綺éºã ããC#ã®åºå¥ããä»æ§ã«è»é ãä¸ããã¨æãã
ä½è¨ãªæ¼ç®åããã¼ã¯ã¼ãããã
VB2005ã§ãã£ã¨æ¼ç®åãªã¼ãã¼ãã¼ããå®è£
ããããã¨ã¯è¿°ã¹ãããããã§å
¨ã¦è§£æ±ºãã訳ã§ã¯ãªããã¦ã¼ã¶ãèªåã§æ¼ç®åãå®ç¾©ããå±é¢ã¯å¤ããã®ã§ã¯ãªãããããä½ãå®ç¾©ããã¹ãã§ã¯ã¯ãªãã¨ããæè¦ããããããåºæ¬çãªã¯ã©ã¹ã®æ¼ç®åã«é¢ãã¦ã¯ãè¨èªè¨è¨æ¸ãèæ¡æ®µéã§æ¨æºã§å®ç¾©ããå¿
è¦ããããæåååã==
æ¼ç®åã§ã¯æ¯è¼ã§ããequal()
ã使ããªãã¨ãããªãæè¨èªãåé¢æ師ã ã
VBã®å ´åã¯å¤åã¨åç
§åã®å ´åã®æ¯è¼æ¼ç®åãç°ãªããå¤åã¯ã¹ã¿ãã¯é åãæ¯è¼ãã¦ãåç
§åã¯ãã¤ã³ã¿ã®ã¢ãã¬ã¹ãåãã¨ãããæãã¦ããã©ãããå¤å®ããæåã®éãããããããä¸å¾=
ã¯é©ç¨ã§ããªãã£ãã®ãçç±ã¨è§£ãããã
// æ§é ä½ if (1 == 2 || 1 != 3) { } // ãªãã¸ã§ã¯ã if (foo == bar || foo != baz ) { }
' æ§é ä½ If 1 = 1 Or 1 <> 3 Then End If ' ãªãã¸ã§ã¯ã If foo Is bar Or foo IsNot baz Then End If
ã¾ããVB6æ代ããã®éºç£ãå©ç¨ãã¦ããã¨ããå´é¢ãããã¨æãã®ã ããVBã¯ã¤ãã³ãé¢ä¿ã§ããåãããæ¼ç®åããã¼ã¯ã¼ãã使ããããã¨ããã§ãC#ã¯ãªã¼ãã¼ãã¼ãããã+=
ã ãã§è¨è¿°ã§ããé¨åãæ£è¦ãããã
// C#ã¯+=æ¼ç®åããªã¼ãã¼ãã¼ãããã¦ãã Button1.Click += new EventHandler(Button1_Click);
' VBã¯ã¡ã½ããå®ç¾©ã«å°ç¨ãã¼ã¯ã¼ã`Handles`ã§è¿½å ãã WithEvents Button1 As Button Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click End Sub ' ãããã¯ã¾ãå¥ã®å°ç¨ãã¼ã¯ã¼ããç¨ãã AddHandler Button1.Click, AddressOf Button1_Click
ã¤ãã³ããçºçãããã«ãä½ãå¤ãªãã®ãã¤ããªãã¨ãããªãã
// C#ã¯ã¡ã½ããã³ã¼ã«ã¨åãæè¦ã§æ¸ãã Event(this, e);
' VBã¯å°ç¨ãã¼ã¯ã¼ãï¼ RaiseEvent Event(this, e);
ããã¯ãªã¼ãã¼ãã¼ãã§ã¯ãªãã¦ãã¼ãµã®åé¡ãããããªãããååã¤ãå¼æ°ã渡ãã¨ãã¯C#ã¿ããã«:
ã§ã¯ãªãã:=
å¦ã«æ°æã¡æªãæ§æãåãã®ã¯GoTo
ã®ã©ãã«ã®:
ã¨åºå¥ã§ããªãã£ãããã»ã»ã»ã£ã¦ãã¨ã¯ãªãããªãã
// C#4.0ãããã£ã¨é ä¸åãã¤ä»»æã®å¼æ°ã ãã渡ããããã«ãªã£ã obj.DoSomething(b: "bar", a: "foo")
' VB6ããã®éºç£ã§ã¯ããã£ã½ãã®ã ã obj.DoSomething(b:="bar", a:="foo")
ã¾ããVB2010ã¾ã§Select
ã§Type
ãç¨ãããã¨ãã§ããªãã£ãã®ã¯ãType
ã«=
æ¼ç®åãå®ç¾©ããã¦ãªãã£ããããããããæ¼ç®åãªã¼ãã¼ãã¼ãã®å®è£
ã®é
ãã®å½±é¿ãã¨æãããã
äºç´èªãC#ããå¤ã
VBã«ããã¦ã¼ã¶ã¼ã使ããããªãäºç´èªã¯ãããªæãã
For
Date
Alias
Default
Declare
End
Error
Event
Function
In
Me
Step
To
With
Rem
Stop
Exit
Until
Loop
ãããå¾
ã¦ããfor
ã¨ãC#ã«ãããã ãï¼ãã¨ã¯æãã ããããä¸ã«è¿°ã¹ãããã«VBã¯å¤§æåã¨å°æåã¯åºå¥ããªãã®ã§å®è³ªçã«ã¦ã¼ã¶ã使ããåèªã®å¶ç´ã¯VBã®æ¹ãå¤ãã.NETã¯ã¡ã½ããåã¯å
é ã ã大æåã§ãã¨ã¯å°æåã¨ããå½åè¦åãä¸è´ãã¦ãã®ã§ãC#ã§ã¯For
ã¨ãWith
ãã¡ã½ããåã«ä½¿ç¨å¯è½ãªã®ã ããã§ã¼ã³ã¡ã½ãããæ¸ãã¨ããªããã¯ããããååã®çãã¡ã½ãããå®ç¾©ããããã¨ãããã ããã
éçã¯ã©ã¹ããªã
C#ã®å ´åã¯ã¡ã³ãã¼å
¨ã¦ãstatic
ã§ã¯ãªãã¨ã³ã³ãã¤ã«ãéããªãéçã¯ã©ã¹ã¨ãããã®ãä½ããããªãããµã³ãã«ã¯å®éã®.NETå
ã®Mathã¯ã©ã¹ã§ããã
public static class Math { public static const Pi = 3.14; public static Decimal Round(Decimal d, int decimals) { return Decimal.Round(d,decimals); } public static Decimal Round(Decimal d, MidpointRounding mode) { return Decimal.Round(d, 0, mode); } public static Decimal Round(Decimal d, int decimals, MidpointRounding mode) { return Decimal.Round(d, decimals, mode); } }
VBã¯åããã¨ããããå ´åã¯ã³ã³ã¹ãã©ã¯ã¿ãprivate
ã«ãã¦ç®è¦ã§å
¨ã¦shared
ã«ãªã£ã¦ãããã¨ã確èªãããããããã¯Module
ã§ä½ããããªãã
Public Module Math Public Const Pi As Float = 3.14 Function Round(ByVal d As Decimal, ByVal decimals As Integer) As Decimal Return Decimal.Round(d, decimals) End Function Function Round(ByVal d As Decimal, ByVal mode As MidpointRounding) As Decimal Return Decimal.Round(d, 0, mode) End Function Function Round(ByVal d As Decimal, ByVal decimals As Integer, _ ByVal mode As MidpointRounding) As Decimal Return Decimal.Round(d, decimals, mode) End Function End Class
ããããModule
ã®ä½ãé§ç®ãã¨ããã¨ãåæã«ã°ãã¼ãã«ãªåå空éãæ±æãã¦ãã¾ããã¨ã ãéçã¯ã©ã¹ã§ããã°usingã§åãè¾¼ã¿ãå½¢åãæå®æå®ããªããã¨ã«ã¯ä½¿ããªãã(ãªããC#6.0ã§ã¯using
ã§ååçç¥ã§ããããã«ããããã)ãModule
ã¯åæã«ä¾µå
¥ãã¦ããããååãè¨è¿°ãã¦æ¸ãã®ã¯ããã¾ã§ä»»æã«ãªã£ã¦ãã¾ãã
ãªããVBã¦ã¼ã¶ã¯åºæ¬çã«Module
ã¯ä½¿ããªãããã¡ããã使ããªãçç±ã¯æ±æäºã
ã§ã¯ãªãã¦ãåã«ç¥ããªãã ãã§ããã
Forã«ã¼ãã®æ±ç¨æ§ãä½ã
æè¿ã®ããã°ã©ãã³ã°ã§ã¯ãã¤ã³ããã¯ã¹ã«ããforã«ã¼ãã¯éæ®ã£ããå°è±¡ãããã®ããã¾ã使ãããªãå°è±¡ãåããã俺ãå¯è½ãªéãä»ã®æ段ãæ¢ãã¦æ¸ãã®ã ããããã©ã¼ãã³ã¹ãæ±ç¨æ§ã¯ãã¯ãforã«ã¼ããä¸çªã¨ã¯æããä½ããã¤ã³ããã¯ã¹å¤ããã¤ã§ãåãåããã¨ããã®ãæãé£ããã¨ãããVBã¯ãã®forã«ã¼ããè¥å¹²å¼±ããä¸è¦ã¯ãçç¥ããå ´åã¯æé»ã§1ãã¤ã¤ã³ã¯ãªã¡ã³ã¿ã«ãã¦ãããVBã®æ¹ãããããããã¨æããããããªãããå®ã¯VBã®æ¹ãå¤§å¹ ã«æ©è½ãå¶éããã¦ããã
for (var i =0; i < arr.length; i++){ // æ大ã®éãã¨ãã¦ã¯C#ã¯;ã§åºåããã3ã¤ã®é¨åãè²ã ã¨ããããã // for ( A; B; C ) // Aï¼ã«ã¼ãã®æåã«å®è¡ãããå¼ãããã¯æãç½®ããã // Bï¼boolããè¿ãã°ä½ã§ãç½®ãããå ¸åçã«ã¯ä½ãã«ã¼ãçµäºã®æ¡ä»¶ãç½®ãããå ´åã // Cï¼ã«ã¼ãã1åçµãããã³ã«ç¹°ãè¿ãããå¼ãæãç½®ããã }
For index = 0 To arr.length ã 'Step nãçç¥ããå ´åã¯æé»ã§Step 1ã«ãªãã Next
ã¾ããä¸ã®ä¾ã ã¨C#ã¯array.length
ã¯ã«ã¼ãã1åçµãã度ã«è©ä¾¡ãããããVBã¯array.length
ã®å¤ã¯ã«ã¼ãéå§æã«ã®ã¿è©ä¾¡ãããã®ã§ãã«ã¼ãä¸ã«å¤åããã¨ãã¦ãã«ã¼ããçµãããã¨ã¯ãªããåçã«çµäºæ¡ä»¶ãå¤æ´ãããã¨ãã§ããBreak
ãªã©ã使ã£ã¦æãããããªãããã£ã¨ããVBã«ã¯Exit For
ãªã©ããã£ã¦å¤å¨ã«ã¼ããä¸æ°ã«æããããã®ã ãã
ãªããVBã¨ã³ã¸ãã¢ã¯å½ç¶LINQãªãã¦çµ¶å¯¾ã«ä½¿ããªãã®ã§ãforã«ã¼ããé »ç¹ã«ç¨ãã¦æ±ãã³ã¼ããããæ¸ãã¦ãããã¨ãå¤ãã
??æ¼ç®åããªã
C#ã®å ´åã¯Nullable
ã®ãªãã¸ã§ã¯ãã«ä»£å
¥ããã¨ããnull
ã ã£ãå ´åã¯å¥ã®å¤ã代å
¥ããã¨ããä¸é
æ¼ç®åã®ã·ã³ã¿ãã¯ã¹ã·ã¥ã¬ã¼ã¿ãããªãã®ãåå¨ããã
var j = i ?? -1;
Dim j As Integer = 0 If i Is Nothing Then j = -1 Else j = i End If
ã¾ããä¸é
æ¼ç®åIf
ã使ãã°VBã§ãä¸è¡ã§æ¸ããããã ãã大æµã®VBã¨ã³ã¸ãã¢ã¯ä¸é
æ¼ç®åãªãã¦ä½¿ããªãããããããã??ã§æ¸ããããã£ã¦ãªãã ãã¿ãããªæããæã¤ãããããªããã¾ãããã¾ãNullable
ã使ããªãããªã
ãã£ã¹ãã®ä»æ§ãæ´ã«é¢åããã
åºæ¬çã«ããã£ã¹ãã¨ã¯ãä»ã¾ã§Aã¨æã£ã¦ãããã®ãBã¨è¦ãªããã¨ããèãã§ããã¨æããããããåºä¹³é¡(ãã®æ£ä½ã¯ç«)ããããã¨ãã¦ãããããåç©ãã¨è¦ãã®ãã¢ããã¼ãã£ã¹ãã§ãããç´°ãããç«ãã¨è¦ãã®ããã¦ã³ãã£ã¹ããç«ã¯åºä¹³é¡ã§ãããåç©ã ãããå ¨ã¦æ£ããã®ã§ãã®ãã£ã¹ãã¯éããããã¾ã§ãä¸èº«(ãã¼ãé å)ãå¤æ´ããã®ã§ã¯ãªããè¦æ¹(ã¹ã¿ãã¯é å)ãå¤æ´ããã®ã ã
C#ã®ãã£ã¹ãã¯2種é¡ãããªããEffective C#ã§ã¯ãas
ã使ããã¨ããããC#ã®null
ã代å
¥ã§ããªãå¤åã¯()
ã§ãã£ã¹ãããªãã¨ããããã¾ãåç
§åãå¿
ãããas
ãéãã¨ã¯ãããªããããªã®ã§ã2種é¡ã®æ¸ãæ¹ãæ··å¨ãããã«ãªã¹ã ãä¾å¤å¦çã¨ã¬ãã½ãã§ãã¯ã®ã©ã£ã¡ãæ¸ããããæ°åã§æ±ºããæãã
var foo = (Foo) hoge; // 失æãããä¾å¤ã var foo as Foo = hoge; // 失æãããnullä»£å ¥ãé«é説ãã
ã¨ãããVB#ã¯3ã¤ããããã®ãã¡TryCast
ã¯as
ã¨åããã®ã¨è¦ã¦ããã¨æãã®ã ããä»ã®2ã¤ã¯C#ã®ãã¬ãã£ãã¯ã¹ãã£ã¹ãã¨ã¯ç°ãªãã
Dim foo = CType(hoge, Foo) ' å¤æãè¡ããé ã Dim foo = DirectCast(hoge, Foo) ' 失æãããä¾å¤ã Dim foo = TryCast(hoge, Foo); ã' 失æãããnullä»£å ¥ãé«é説ãã
ãã®ãã¡ãDirectCast
ã¯C#ã®()
ããé ã硬ãã
int i = 1; short s = (short)i;
Dim i As Integer = 1 Dim s = DirectCast(i, Short) 'ã¨ã©ã¼
ãã¨ããã°ãC#ã¯ãã¤ã«ã«ãµã¤ãºã®ã¯ã¸ã©ãããã°ã¤ã«ã«ã¨å¼ãã§ããããããªãããã¨è¨ã£ã¦ãã®ã«å¯¾ãã¦ãVBã¯ãã¯ã¸ã©ã¨ã¤ã«ã«ã¯éããã©ããã¦ãã¯ã¸ã©ãã¤ã«ã«ã¨å¼ã³ãããã°ãã¯ã¸ã©ãã¤ã«ã«ã«å¤æããï¼ãã¨è¨ãå¼µããããªæãã§ãã©ãè¦ã¦ãC#ã®æ¹ãæè»ã§ããåççã ã
CType
ã¯ãã£ã¹ãã§ã¯ãªãã¦ãå¤æãã«è¿ããè¦æ¹ãå¤ããã®ã§ãªãä¸èº«ãå¤ãããã¨ããã®ã ãããã¯éçè¨èªã§ããªãã£ãæ代ããã®è² ã®éºç£ãããããCTYPE("1", 1)
ãªãã¦ã³ã¼ããéããã.NETã§ã¯ãªãã¦VBç¹æ®ã®å®è£
ããããåºæ¬çã«ã¯VBã§ã¯DirectCast
ãTryCast
ã®ã¿ã使ããã©ã£ã¡ã使ããã¯æ°åã§é¸ã¹ã°ããã¨æããããããC#ã¯()
ã¨as
ã¯ã·ã³ã¿ãã¯ã¹ãéãã®ã§å人ã®ç¾è¦³ã«ãããã®ã ããVBã¯ã©ã¡ããé¢æ°ã¿ãããªæ¼ç®åãªã®ã§é¢ç½ã¿ããªãã
VSã®ã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ããC#ããå¶éããã¦ããã
ããã¯MSã®æ æ ¢ãªã®ãããããªãããæ´å²ççµç·¯()ã¨ããããã¤ãªã®ãããããªããã代表çãªã¨ããã§ã¯C#ã ã¨ã¯ã©ã¹ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãæ§é ä½ãåæåã®å ¨ã¦ãè²åãã§ãããVBã¯å ¨ã¦ä¸è²ã§ããããã ã§ããC#ããæåã®å§è¿«æãå¼·ãã¦ç¾ãããªãåé¢ã«ãªããããã¨ããã®ã«ãããããæã§ãå·®ãã¤ãããã¦ãã¦ã¯ãVBã§ç¾ããã³ã¼ããæ¸ãããã¨ããæ欲ã失ããã¨ãããã®ã ã
ãã¡ãããMSã®ä¸ã®äººããVBã¨ã³ã¸ãã¢ã¯ã©ããã¤ã³ã¿ã¼ãã§ã¤ã¹ãæ§é ä½ãåæåãªãã¦ä½¿ããªãã ããã¨æã£ã¦ãã®ä»æ§ã«ããã®ãããããªããããã®å¯è½æ§ã¯å®å ¨ã«ã¯å¦å®ã§ããªããã¨ããã®ãã俺ã¯VBã§æ¸ãããã³ã¼ãã§ãèªåéã§ã¤ã³ã¿ã¼ãã§ã¤ã¹ãæ§é ä½ãåæåãå®ç¾©ãã¦ãã¨ããã¯ä¸åº¦ãè¦ããã¨ããªãã
å¤æ°ã®æé»ã®åæåãæãã
C#ã¯ãã¼ã«ã«å¤æ°ã«å¯¾ãã¦ã¯å®£è¨ã¨åæã«ä»£å ¥ãå¿ è¦ã§ããããVBã¯æ´å²ççµç·¯ããã宣è¨ã ãã§ãããããã®å ´åã¯ãèªåçã«ããã©ã«ãå¤ãè¨å®ãã¦ããããããããã ãååã®è¡ã§æ¸ãä»£å ¥ï¼å®£è¨å¦çãããããåã®è¡ã§æ¸ãé¿åãå¤ãã®ã§ããã¡ãªããã¨ããã°ãã¡ãªããã«ããªã£ã¦ãããããããªãã
var x = 100 var s = "foo"
Dim x As Integer Dim s As String x = 100 s = "foo"
ããã«ããC#ãåç
§æ¸¡ãããå¼æ°ãåæåãã渡ãå ´åã®out
ã¨ãç´°ãããã¼ã¯ã¼ã追å ããã¦ãåããVBã¯ãã®ã¾ã¾æ¸¡ããããããã
ãã ããå¾®å¦ã«æããé¨åããããä¾ãã°ãString
ã®åæå¤ã¯Empty
ã§ãªãNothing
(null
)ãªã®ã§ãC#ã¨åãããIsEmpty
ã使ãç©ã«ãªãããString.IsNullOrEmpty()
ã使ããªãã¨ãããªã(ãString
ããªãã¸ã§ã¯ã(åç
§å)ãªãã ããä»ã¨åãåä½ã«ããªãã¨ãããªãã ãï¼ãã¨æã人ã¯ãæåã®æ¯è¼ã«==
ã§ã¯ãªãã¦equal
ã使ããªãã¨ãããªãæè¨èªã§ãã©ãã)ã
æååã¯ãªãã¸ã§ã¯ãã¨è¨ã£ã¦ãããç¹æ®ãªã®ã§åæå¤ãEmpty
ã«ãã¦ãããã ãã¶å¿«é©ã ã£ãã¨æãããã¡ãã.NETå
¨ä½ã§Nothing
(null
)ã¯ãªãã¸ã§ã¯ãã§ã¯ãªãã¨ããæ±ããªã®ã§ãVBã ãã§ãªãC#ã®æ¬ ç¹ã§ãããã®ã ããæè§åæå¤ãªãã¦ãã®ãããVBã¯ã¨ããããå¿ä½ç¡ããã¨ããæããããã
' objãã¤ã³ã¹ã¿ã³ã¹ãåç §ãã¦ãã¨ã¯éããªãã®ã§å¤§æµã®å ´åããã¯ä½¿ããªã If obj.IsEmpty Then End If ' ãããå®ç If Strings.IsNullOrEmpty(obj) Then End
ã¾ãããã¼ã«ã«å¤æ°ã«åæå¤ããããªãã°ãã©ããã¦ãªãã·ã§ã³å¼æ°ã«ããã©ã«ãå¤ã®è¨å®ãå¿
è¦ãªãã ãããï¼ C#ã®ããã«ããã©ã«ãå¼æ°ã®æç¡ã§çç¥å¯è½ã«ãã¦ãããªãåããããåè¿°ããããã«VBã®å ´åã¯ãã¡ãã¡å
¨ã¦ã®å¼æ°ã®é ã«Optional
ãã¤ããªãã¨ãããªã訳ã§ã»ã»ã»ã.NET以åããããä»æ§ã ããéå»ã®è² ã®éºç£ãªãã ãããã©ãå®æ度ã¨ããæå³ã§ã¯æããã
Sub DoSomething(Byval Optional i As Integer) ' ããã©ã«ãå¤ãæ¸ãã¦ãªãã®ã§ã¨ã©ã¼ãåºã End
ä¸é æ¼ç®åã®åºæ¥ãæªã
VB6ããIIf()
é¢æ°ããã£ãããéã«2008å¹´ã«If
æ¼ç®åãå°å
¥ããããã¨ãããæ¼ç®åãªã®ã«é¢æ°ã¿ãããªã·ã³ã¿ãã¯ã¹ãæ¡ç¨ãã¦ããã®ã§ä¸é
æ¼ç®åã®ç¾ããã¿ãããªãã®ã微塵ã«ãæããããªããã®ã«ã¯ãªã£ã¦ãããä¸å¿åå®å
¨ã ããã¹ããã§ããã®ã ããåæ¨è«ãå£ãã¦ãããä¸ã®ã±ã¼ã¹ã¯C#ã ã¨ã³ã³ãã¤ã©ãéããªããVBã ã¨éã£ã¦ãã¾ãã
// æå¾ãæ°å¤åãªã®ã§ã¨ã©ã¼ã«ãªã var x = (foo) ? "hoge" : (bar) ? 'fuga' : 1;
' VBã³ã³ãã¤ã©ã¯ãããæ¤åºã§ããªãã Dim x = If(foo, "bar", If(bar, "fuga", 1))
ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®å®è£ ã¯å¸¸ã«ååã¨ã¡ã½ããåãè¦æ±ããã
C#ã¯ã¤ã³ã¿ã¼ãã§ã¤ã¹ã§å®è£ ããã¡ã½ããã¯ãå®è£ å ã¨ååã«ããªãã¨ãããªãã¨ããå¶ç´ãããããã¾ãã¾è¤æ°ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ãååã®ã¡ã½ãããæã£ã¦ããããããå®è£ ã¯å¥ã«ãããå ´åã¯ååãæ示ãããã¨ã§åãããã¨ãã§ãããGoè¨èªã®ãååã®ã¡ã½ãããæã£ã¦ããéãã¯åãåã¨è¦ãªããã¨ããæãåãã®è¯ãã¯ãªãããC#ã¯å®ã«åçæ§ã«æº¢ããä»æ§ã ã
class ImplementationClass : ISampleInterface { // ISampleInterface.SampleMethod()ã¨æ示çã«æ¸ãã¦ããã void SampleMethod() { } }
ããã«æ¯ã¹ã¦VBã¯ã¡ã½ããåãåãã ãããç°ãªããã常ã«ã¤ã³ã¿ã¼ãã§ã¤ã¹åãæ示ããªãã¨ãããªããããã¯VB5.0ã§å°å ¥ãããã¤ã³ã¿ã¼ãã§ã¤ã¹ã®å®è£ æ¹æ³ãå¼ãããæ´å²ççµç·¯ãªã®ãããããªã(ãã¡ããVBã¯ãã®ä»£åã¨ãã¦å®è£ å ã§ã¡ã½ããåãå¤æ´ã§ããããããããããã«æããã¦å¤§ããªå©ç¹ãããã®ã ããããå ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ãä½ãã«ã©ããããããªãå½åããã¦ãã¦å¤æ´ãããã®ã§ããã°ãC#ã§ãå¥åã®ã¡ã½ããã«ã©ããããã°åããã¨ãã§ãã)ã
Class ImplementationClass Implements ISampleInterface Sub Hoge() Implements ISampleInterface.SampleMethod ' ã¤ã³ã¿ã¼ãã§ã¤ã¹åãæ示çã«æ¸ããªãã¨ã³ã³ãã¤ã«ã¨ã©ã¼ End Sub End Class
ãã ãæè¨èªã«ã¯@Override
ã¨ãã³ã³ãã¤ã©ã®é½åã¨ãã§ã¯ãªããå¯èªæ§ã®ããã ãã«ä»»æã§ã¤ã³ã¿ã¼ãã§ã¤ã¹ç±æ¥ã®ã¡ã½ããã¨ãããã¨ã示ãããã®ã¢ããã¼ã·ã§ã³ããããVBã¯ãããå¼·å¶ããèªã人éãåããããããããã®ã¨ãè¨ãããC#ã¯ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®ã¡ã½ããã«override
ãã¼ã¯ã¼ããã¤ããã®ã¯ç¦æ¢ãã¦ããããã¤ã³ã¿ã¼ãã§ã¤ã¹åã¨ã¡ã½ããåãä»»æã§æ¸ããã¨ã¯è¨±ãã¦ããã®ã§ãC#ã¯åé·æ§ãå»ãã¦ä»»æã¨ããVBã¯åé·æ§ãåãå¿
é ã¨ããã¨ããç«å ´ã®éãã®è©±ãããããªãã
volatileããªã
å人çã«ã¯ãvolatile
ã¯åãªããã¾ããªãç¨åº¦ã«èãã¦ããããlock
ãinterlock
ã¨éã£ã¦ãVBã§ã¯ãªãããã¼ã¯ã¼ãã¨ãã¦ç¨æããã¦ããªãããªã®ã§ããã¡ãã¡ã¡ã½ããå
ã§Thread.VolatileRead()
ãVolatileWrite()
ãå¼ã¶ãããªãã
è¤æ°è¡ã®ã³ã¡ã³ããã§ããªã
C#ã¯//
ã®åä¸è¡ã³ã¡ã³ãã ãã§ãªãè¤æ°è¡ã³ã¡ã³ããã§ããããã ã俺ã¯ã©ã®è¨èªã§ãè¤æ°è¡ã³ã¡ã³ãã¢ã¦ãã¯ä½¿ãåæããã¾ãè¯ããªãã®ã§ãããã«ã¤ãã¦ã¯æ®æ´VBã®æ¬ ç¹ã¨ãã¦èªãã¤ããã¯ãªããå¤åãã®ã¾ã¾ã§ãååã ããæ¾ç½®ããã¦ãããã ã¨æããéã«CSSã¿ããã«/* */
ããç¨æããã¦ããªãã¨ããæ²æ¨ãªä¾ãã
/* ãã³ã¡ã³ãã§ã */
' ' ã³ã¡ã³ãã§ã '
ãªãäºææ§ãèãã¦ãVBã«ã¯REM
(ãRemarkãã®ç¥ã ã¨ããã®ãé説)ã¨ãããã¼ã¯ã¼ããç¨æããã¦ããã誰å¾ãªãã ããã£ãã¨å»æ¢ãã¦ããã ããã
ä½æ ãç¹å®ã®å ´é¢ã§ã¡ã½ããå¼ã³åºããææ±ããããªãã
åºæ¬çã«ã¡ã½ããå¼ã³åºããä»£å ¥ã¯æã«ãªãã¯ãã ããVBã®å ´åã¤ã³ã¹ã¿ã³ã¹ãä½ãã¨åæã«ã¡ã½ãããå¼ã³åºããã¨ã¯ãªããã§ããªãã
new Hoge().DoSomething();
Dim hoge = new Hoge() hoge.DoSomething()
ãããåé¿ããã«ã¯VB6æ代ã®éºç£ã§ããCall
ã使ããããªãã
unsafeããªããçãã¤ã³ã¿ãã¤ã¸ããªã
ãããä¸çªå¤§ããã¨æãã人ãããã ããããå人çã«ã¯å®åã§ã¯ä¸åº¦ã使ã£ããã¨ç¡ãããã®ç«å ´ã§ãVBã¯ããããªãããé§ç®ãã¨ããã®ã¯ãã§ã¢ã§ã¯ãªãã®ã§æ¯è¼ææã¨ãã¦ã¯é©åã¨æããªãããã¤ãæè¨èªã¨C#ãæ¯è¼ããã¨ãã«ãããã¯è§¦ããªãã£ããã¨ããããC#ã¯Cã®ååãå ãã¦ãããã¨ããããã¡ã¢ãªãç´æ¥æä½ã§ããã
æããç»åæ åå¦çãªã©ããã©ã¼ãã³ã¹ãåããããã®ãå®è£ ãããã®ã§ããã°VBã§ãªãC#ã«ãªãã ãããå®éC#ã¯UnityãPS4ã®ã²ã¼ã éçºãªã©ã§ã使ããã¦ããã©ãVBã¯ã»ã»ã»ã
unsafe static void Main(string[] args) { double pi = 3.14; double * pip = π }
ã»ã»ã»ãã¨ã¯ã¾ããä»ã«ãç¡æ°ã«ç´°ããè¨èªä»æ§ã®éããããã ãããã俺ã¯è¨èªä»æ§ã®ç 究è ã§ããªãã®ã§å ¨ã¦ã¯æããããªããããã以ä¸ç¡çã«è¨èªä»æ§ã®æ¬ ç¹ãããã¤ãããã¨ããã°ããã»ã©ãæ¹ãã¦ä»ã®VBã«ã¯éã¯ãªããªã¨æãã¦ãã¾ããæè¿ã¯TypeScriptã«ãç±ããããããã¤ã¯ãã½ããã®C#ã¨VBã®å·®ç°ãç¡ãããã¨ããå°½åã«ã¯é©ãã ã
æè¿ã®è¨èªã®æ½®æµãè¦ãã°ãææ«ã®;
ãä¸è¦ãªVBã®æ¹ãæåã§è¨å
¥ãå¼·ããC#ããçã«é©ã£ã¦ãããSwitch
ã¯C#ã®select
ããã¾ã¨ããªä»æ§ã ããå¼æ°ãªãã®ã¡ã½ããã¯()ãçç¥ã§ããã®ã好ãã ããã¾ã使ãããå¼æ°ã¤ãããããã£ãããã2010å¹´ã¾ã§C#ã«ãå®è£
ãé
ãã¦ããè¦ç´ ãããã¤ããã°ãVBã¯C#ããä¸ãã¨ããæè¦ãåºããã»ã»ã»ãããããªããçµå±ã¯è¨èªèªä½ã¯æªããªããã ããªã使ã人ã¨ç¤¾ä¼ãæªãããã
ç·è«
VB.NETã¯é常ã«ããåºæ¥ãè¨èªã§ãããC#ã¨æ¯è¼ãã¦ãæ©è½æ§ã«éè²ã¯ãªããããããVBãæ¡ç¨ãã¦ããç¾å ´ã§ã¾ã¨ããªã³ã¼ãã£ã³ã°ãã§ãããã¨ã¯ãªãã ãããã¨ããã®ããVBã®ç¾å ´ã§è¦ãããæåã»å²å¦ã¯ãä»æ¥ã®ã½ããã¦ã§ã¢å·¥å¦ã«ãããçæ³ã®ããã¨è¦äºãªã¾ã§ã«å¯¾ç §çã ããã ã
çæ³ | VB |
---|---|
ãªãã¸ã§ã¯ãæå (+é¢æ°å) | åé·æ§æåæç¶ãå |
Don't Repeat Yourself | Write Everything Twice |
é¢å¿ã®åé¢ | é¢å¿ã®éç´ (ä¾ï¼å ¨ã¦ãã³ã¼ãããã¤ã³ãã«) |
人ã¯ãã¹ããã | 人ã¯ãã¹ããã¦ã¯ãããªã |
ç¡é§ãªãã®ã¯æ¶ã / KISS | ã«ã¼ã´ã»ã«ã«ã |
èªåå | æåã»ç®è¦ã»äººæµ·æ¦è¡ |
æ½è±¡åif (person.isActive) |
å
·è±¡åIf objPerson.strActiveStatus = "1" |
There's only one way to do it. There's more than one way to do it. |
There's only one oldie way to do it |
ãã«ã¹ã¿ãã¯ã¨ã³ã¸ã㢠| èªç§°ããã©ã³ãã¯ã©ãµãå°é家 |
èªç¤¾éçº | åè¨éçºã客å 常é§ãå½è£ è«è² ãå¤éæ´¾é£ |
è½å主義 | å¹´ååºåãä¸æãããã³ããã人æå価 |
ãã¡ãããC#(ã¤ãã§è¨ãã°RubyãPythonãScalaãGoã)ãæ¡ç¨ãã¦ãã¦ãè¯ããªãç¾å ´ã¯ããã¨æããã§ãæåã«æ¸ããéããVBã使ã£ã¦ããç¾å ´ã¯99.99%ãã¯ã½ã ãããC#ã§æ¸ãããããã¸ã§ã¯ãã§ã¯ã½ã³ã¼ããã¢ã³ããã©ã¯ãã£ã¹ãå®è·µããã¦ããããããã¯å¤åC#ã®æåã¨ããããã¯ãVBçã®äººéãä½ã£ãC#ããã¸ã§ã¯ããªããããªãããªã¨æã(ããæååã®æ¯è¼ã«Equal()
ã使ããã¦ãããééããªãJavaçã ãããã©)ã
VBAããVB.NETã«ããã¦ãVisual Basicã¨ããè¨èªã«ã¯é·ããã¨ä»ãåã£ã¦ãããVBã¨ããè¨èªã好ãã«ãªããã¨é å¼µã£ã¦ããããä»ã§ãè¨èªãã®ãã®ã®å®æ度ã¯èªããããå¾ãªãããªãã¨ãéå»ã«æ¸ãããã¯ã½ã³ã¼ããã¯ã½ç¿æ £ãå¤ãããã¨é å¼µã£ãããã¦ãããã©ãæçµçã«ã¯è«¦ãã¦ãVBã«ã¯å¹»æ» ãã¦ãäºåº¦ã¨VBã ãã¯æ¸ããªãã¨æ±ºããããªããªããVBã§ã³ã¼ãã£ã³ã°ããããã¨ã¯ãããã°ã©ãã³ã°ãå«ãã«ãªããã¨ã«çããããã ã
ã³ã¼ãã£ã³ã°ã楽ãã¿ããã | â | VBã¯ã³ã¼ãã£ã³ã°ä½æ¥ãã¤ã¾ããªãã |
æ°ãããã¨ãã©ãã©ãè¦ãããã | â | VBã¯æ°ãããã¨ã¯è¦ããããªãã |
èªåã®ã¢ã¤ãã¢ã¨åµé æ§ãã³ã¼ãã§æãã¦å±ãããã | â | VBã¯åã«ã¯ã¾ã£ãã³ããã³ã¼ããå¼·å¶ãããã |
ãµã¼ãã¹ã製åã®æ©è½ãä»æ§ãèãã¦ææ¡ãããã | â | VBã¯ä½æ¥å¡ãææ¡ãçæ³ã¯ã§ããªãã |
èªåã®æè¡ã¨ã»ã³ã¹ãè©ä¾¡ãã¦è²°ãããã | â | VBã¯å¹´åãå¤éè«è² ã§ã®èªåã®é層ä½ç½®ãè©ä¾¡ã決ããã |
åççã®ãããªãæã«ã¯éå»ã®æ £ç¿ãªãã¦æ¨ã¦ããã | â | VBã¯å½¢å¼ã¨éå»ã®æ £ä¾ãåéè¦ã |
å®åã«è¦ãã£ãé«ã給æãè²°ãããã | â | VBã¯é«ã給æã¯è²°ãã«ããã |
人ãäºåº¦ã¨VBã¯æ¸ããªãçç±ã¨ãã¦ã¯ååéããã ããã