æ°ç»å¿
é¡»å
å®ä¹(声æ)ï¼ç¶åæè½èµå¼ã
ä¸é¢å
¨é¢è®²è§£æ°ç»çç¸å
³ç¥è¯ï¼
æ°ç»çæ¦å¿µ
1ï¼å¼ä¾
ããæ±100个å¦ççå¹³åæ绩åè¶
è¿å¹³åæ绩ç人æ°ã
ããå¦æç¨ä¸è¬åéæ¥è¡¨ç¤ºæ绩ï¼éè¦ç¨100个åéï¼å¦ï¼mark1ãmary2ãâ¦â¦mark100ãè¥ç¨æ°ç»ï¼å¯ä»¥åªç¨ä¸ä¸ªæ¥è¡¨ç¤ºmarkï¼1
Toã100ï¼ã
2ï¼åºæ¬æ¦å¿µ
ããæ°ç»ï¼æ¯åç±»ååéçä¸ä¸ªæåºçéåã
ãã ãå¦ï¼Aï¼1To 100ï¼ï¼è¡¨ç¤ºä¸ä¸ªå
å«100个æ°ç»å
ç´ çå为Açæ°ç»ã
ããæ°ç»å
ç´ ï¼ å³æ°ç»ä¸çåéãç¨ä¸æ 表示æ°ç»ä¸çå个å
ç´ ã
ã表示æ¹æ³ï¼æ°ç»åï¼P1ï¼P2ï¼â¦â¦ï¼
ãããå
¶ä¸P1ãP2表示å
ç´ å¨æ°ç»ä¸çæåä½ç½®ï¼ç§°ä¸ºâä¸æ âã
ãå¦ï¼Aï¼3ï¼2ï¼ä»£è¡¨
äºç»´æ°ç»Aä¸ç¬¬3è¡ç¬¬2åä¸çé£ä¸ªå
ç´ ã
ããæ°ç»ç»´æ°ï¼ ç±æ°ç»å
ç´ ä¸ä¸æ ç个æ°å³å®ï¼ä¸ä¸ªä¸æ 表示ä¸ç»´æ°ç»ï¼äºä¸ªä¸æ 表示äºç»´æ°ç»ã
ãã VBä¸æä¸ç»´æ°ç»ãäºç»´æ°ç»ãâ¦â¦æå¤60ç»´æ°ç»ã
ããä¸æ ï¼ ä¸æ 表示顺åºå·ï¼æ¯ä¸ªæ°ç»æä¸ä¸ªå¯ä¸ç顺åºå·ï¼ä¸æ ä¸è½è¶
è¿æ°ç»å£°ææ¶çä¸ãä¸çèå´ãä¸æ å¯ä»¥æ¯æ´åç常æ°ãåéã
表达å¼ï¼çè³åæ¯ä¸ä¸ªæ°ç»å
ç´ ã
ãããããä¸æ çåå¼èå´æ¯ï¼ä¸ç To ä¸ç ï¼ç¼ºçä¸çæ¶ï¼ç³»ç»é»è®¤å0ã
3ï¼æ°ç»å£°æ
ãæ°ç»å¿
é¡»å
声æå使ç¨ã声ææ°ç»å°±æ¯è®©ç³»ç»å¨å
åä¸åé
ä¸ä¸ªè¿ç»çåºåï¼ç¨æ¥åå¨æ°ç»å
ç´ ã
ã声æå
容ï¼æ°ç»åãç±»åãç»´æ°ãæ°ç»å¤§å°ã
ããããããä¸è¬æ
åµä¸ï¼æ°ç»ä¸åå
ç´ ç±»åå¿
é¡»ç¸åï¼ä½è¥æ°ç»ä¸ºVariantæ¶ï¼å¯å
å«ä¸åç±»åçæ°æ®ã
ãéææ°ç»ï¼å£°ææ¶ç¡®å®äºå¤§å°çæ°ç»ã
ãå¨ææ°ç»ï¼ 声ææ¶æ²¡æç»å®æ°ç»å¤§å°ï¼çç¥äºæ¬å·ä¸çä¸æ ï¼ï¼ä½¿ç¨æ¶éè¦ç¨ReDimè¯å¥éæ°æåºå
¶å¤§å°ã
éææ°ç»å声æ
1ï¼ ä¸ç»´æ°ç»
éæä¸ç»´æ°ç»ç声æå½¢å¼ï¼
Dim æ°ç»åï¼ä¸æ ï¼ [As ç±»å]
说æï¼ï¼1ï¼ä¸æ å¿
须为常æ°ï¼ä¸å¯ä»¥ä¸ºè¡¨è¾¾å¼æåéï¼
ããã ï¼2ï¼ä¸æ ä¸çæå°ä¸º-32768ï¼æ大ä¸ç为32767ï¼çç¥ä¸çï¼å
¶é»è®¤å¼ä¸ºä¸º0ï¼ä¸ç»´æ°ç»ç大å°ä¸ºï¼ä¸ç-ä¸ç+1
ããã ï¼3ï¼ å¦æçç¥ç±»åï¼å为åä½å
ä¾ï¼ãï¼1ï¼ Dim Aï¼10ï¼ As Integer
ãããã ã声æäºAæ¯æ°ç»åãæ´åãä¸ç»´æ°ç»ãæ11个å
ç´ ï¼ä¸æ çèå´æ¯0ï½10ã
ãã ï¼2ï¼ Dim Bï¼-3 To 5ï¼ As String*3
ããããã 声æäºBæ¯æ°ç»åãå符串åãä¸ç»´æ°ç»ãæ9个å
ç´ ï¼ä¸æ çèå´æ¯-3ï½5ï¼æ¯ä¸ªå
ç´ æå¤åæ¾3个å符ã
2ï¼å¤ç»´æ°ç»
ããéæå¤ç»´æ°ç»ç声æå½¢å¼ï¼
Dim æ°ç»åï¼ä¸æ 1[ï¼ä¸æ 2â¦]ï¼ [As ç±»å]
ãã说æï¼ãï¼1ï¼ä¸æ 个æ°å³å®æ°ç»çç»´æ°ï¼æå¤60ç»´ã
ããããã ï¼2ï¼æ¯ä¸ç»´ç大å°=ä¸ç-ä¸ç+1ï¼æ°ç»ç大å°=æ¯ä¸ç»´å¤§å°çä¹ç§¯ã
ããä¾ï¼Dim Cï¼-1To 5ï¼ 4ï¼ As Long
ã ãã声æäºCæ¯æ°ç»åã
é¿æ´åãäºç»´æ°ç»ã第ä¸ç»´ä¸æ èå´ä¸º-1ï½5ï¼ç¬¬äºç»´ä¸æ çèå´æ¯0ï½4ï¼å æ®7x 5个é¿æ´ååéç空é´ã
3ï¼æ³¨æäºé¡¹
ããï¼1ï¼å¨æäºè¯è¨ä¸ï¼ä¸çä¸è¬ä»1å¼å§ï¼ä¸ºäºä¾¿äºä½¿ç¨ï¼å¨VBççªä½å±ææ å模åå±ç¨Option Base n è¯å¥å¯éæ°è®¾å®æ°ç»çä¸çï¼å¦Option Base 1ã
ã ï¼2ï¼ å¨æ°ç»å£°æä¸çä¸æ å
³ç³»å°æ¯ä¸ç»´ç大å°ï¼æ¯æ°ç»è¯´æ符ï¼èå¨ç¨åºå
¶ä»å°æ¹åºç°çä¸æ 为æ°ç»å
ç´ ï¼ä¸¤è
åæ³ç¸åï¼ä½æä¹ä¸åã
ã ï¼3ï¼ å¨æ°ç»å£°ææ¶çä¸æ åªè½æ¯å¸¸æ°ï¼èå¨å
¶ä»å°æ¹åºç°çæ°ç»å
ç´ çä¸æ å¯ä»¥æ¯åéã
å¨ææ°ç»å声æ
1ï¼ å¨ææ°ç»ç建ç«ä¸å£°æ
ãã建ç«å¨ææ°ç»çæ¹æ³æ¯ï¼å©ç¨DimãPrivateãPublicè¯å¥å£°ææ¬å·å
为空çæ°ç»ï¼ç¶åå¨è¿ç¨ä¸ç¨ReDimè¯å¥ææ该æ°ç»ç大å°ãè¯æ³æ¯ï¼
ReDim æ°ç»åï¼ä¸æ 1[ï¼ä¸æ 2â¦]ï¼ [As ç±»å]
ã å
¶ä¸ä¸æ å¯ä»¥æ¯
常éï¼ä¹å¯ä»¥æ¯æäºç¡®å®å¼çåéï¼ç±»åå¯ä»¥çç¥ï¼è¥ä¸çç¥ï¼å¿
é¡»ä¸Dimä¸ç声æè¯å¥ä¿æä¸è´ã
ããä¾ï¼ Dim Dï¼ï¼ As Single
ãããã Sub Form_Loadï¼ï¼
ãããã â¦â¦
ãããã ReDim Dï¼4ï¼6ï¼
ãããã â¦â¦
ãããã End Sub
2ï¼æ³¨æäºé¡¹
ããï¼1ï¼å¨å¨ææ°ç»ReDimè¯å¥ä¸çä¸æ å¯ä»¥æ¯å¸¸éï¼ä¹å¯ä»¥æ¯æäºç¡®å®å¼çåéï¼
ã ï¼2ï¼å¨è¿ç¨ä¸å¯ä»¥å¤æ¬¡ä½¿ç¨ReDimæ¥æ¹åæ°ç»ç大å°ï¼ä¹å¯æ¹åæ°ç»çç»´æ°ã
ã ï¼3ï¼æ¯æ¬¡ä½¿ç¨ReDimè¯å¥é½ä¼ä½¿åæ¥æ°ç»ä¸çå¼ä¸¢å¤±ï¼å¯ä»¥å¨ReDimè¯å¥åå Preserveåæ°æ¥ä¿çæ°ç»ä¸çæ°æ®ï¼ä½ä½¿ç¨Preserveåªè½æ¹åæåä¸ç»´ç大å°ï¼åé¢
å 维大å°ä¸è½æ¹åã
使ç¨å¨ææ°ç»çä¼ç¹æ¯æ ¹æ®ç¨æ·éè¦ï¼ææå°å©ç¨åå¨ç©ºé´ï¼å®æ¯å¨ç¨åºæ§è¡å°ReDimè¯å¥æ¶æåé
åå¨åå
ï¼èéææ°ç»æ¯å¨ç¨åºç¼è¯æ¶åé
åå¨åå
ã