龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VB开发 >

在VB5中如何使机箱内的小喇叭发出不同的声音?

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
->-chengdx 回答1: Mmsound.drv是小喇叭的系统接口,很多API的书都有用法介绍 -219张晶 回答2: 使用VB中的beep语句,但这只能发出一种声音。如果想发出不同声音,可以 使用API函数。详情如下
->-chengdx
  回答1:
  Mmsound.drv是小喇叭的系统接口,很多API的书都有用法介绍
  -219张晶
  回答2:
  使用VB中的beep语句,但这只能发出一种声音。如果想发出不同声音,可以
  使用API函数。详情如下:(摘自VB-Helper)
  UsetheBeepAPIfunction.
  
  Thisexampledemonstratestwointerestingthings.First,itshowshowtomakeabeepofanyfrequencyanddurationratherthanusingthestandardtoneyougetwiththeBeepstatement.
  
  Second,notethattheBeepAPIfunctionhasthesamenameasVisualBasic'sBeepstatement.Todifferentiatethem,youcanassignanewnametotheBeepAPIfunctioninitsDeclarestatement.Itisknownas"Beep"inthelibrary(theAliasstatement)butitisknownasAPIBeeptotheprogram.
  
  Youcanusethistechniquetodifferentiatebetweenfunctionswiththesamename,oryoucanuseittogiveAPIfunctionsanamethatiseasiertowrite(forexample,iftheAPInameisverylong).
  
  Inthedeclarationssection:
  
  OptionExplicit
  PrivateDeclareFunctionAPIBeepLib"kernel32"Alias"Beep"(ByValdwFreqAsLong,ByValdwDurationAsLong)AsLong
  'Tomakeabeeplasting500millisecondswithfrequencyspecifiedinthe
  'TextBoxtxtFrequency(try1000forstarters):
  
  PrivateSubCommand1_Click()
  DimfrequencyAsLong
  
  frequency=CLng(txtFrequency.Text)
  APIBeepfrequency,500
  EndSub
  -Prisoner->
->

精彩图集

赞助商链接