Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 2 decades ago

拜託高手幫我註解三行短程式碼,謝囉

If App.PrevInstance = True Then End

AppDir = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\")

MainDatabase = AppDir & "itcafestrategy.mdb"

1 Answer

Rating
  • 2 decades ago
    Favorite Answer

    要先介紹一下,在Windows的系統中每個程式都會有一個Handle和

    Instance,Handle是一個程式的編號,Instance則是代表程式的實體

    第一行是判斷如果這個程式在系統裡已經被執行,則程式馬上

    結束,這是一般想讓一個程式只能執行一個實體的做法,像

    Yahoo的即時通或MSN的程式都是這樣做。

    第二行是取得程式執行的路徑,如果取得的路徑是"xxxxxxxxx

    xxxxx\",則將其copy到AppDir,否則將路徑加上"\",再copy到

    AppDir,主要是取得程式執行的路徑,例如:程式是在

    "C:\aaa\bbb\project1.exe",App.Path所取得的字串就是"C:\aaa\bbb\"。

    第三行是做字串的And,將剛剛的路徑再加上"itcafestrategy.mdb"

    ,並copy到MainDatabase,如果現在AppDir的內容是"C:\aaa\bbb\"

    ,執行這行後MainDatabase的內容就是"C:\aaa\bbb\itcafestrategy.mdb"。

Still have questions? Get your answers by asking now.