VB+Excel 動態DDE

該如何用VB6.0讀取EXCEL的動態數值(DDE)

假設我的DDE每秒會更新數值,那我怎麼把它每秒的的新數值顯示在我的表單上(Textbox裡面←他是一個陣列)??

有沒有範例?? 我報告快要交不出來了!! 想破頭都不知道看哪些書找哪些網站

linkmode 、 linktopic 、 linkItem 、linkmode到底是什麼呢??

如果我想讓excel A1~A10 的數值 填到 Textbox(0~9) 裡面

Textbox的 linkmode、linktopic、 linkItem、linkmode 我該如何去設定呢??

問題還是出在連結 我真的搞不懂VB6.0和excel到底怎麼連結的!!!

Update:

W大大 :

請問依下我的表單需要有哪些物件??

老實說看不怎麼懂你所宣告的東西

.dll 檔 他是一個模組嗎?

1 Answer

Rating
  • W.J.S.
    Lv 7
    1 decade ago
    Favorite Answer

    '直接在檔案總管或我的電腦將你的.xls拖曳到表單中

    Private Declare Sub ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal h&, ByVal L$, ByVal f$, ByVal P$, ByVal D$, ByVal s&)

    Private Declare Function GetActiveWindow Lib "User32" () As Long

    Private Declare Sub SetWindowPos Lib "User32" (ByVal h&, ByVal w&, ByVal X&, ByVal Y&, ByVal cx&, ByVal cy&, ByVal f&)

    Private Sub Form_Load()

    OLEDropMode = 1

    SetWindowPos hWnd, -1, 0, 0, 0, 0, 83

    End Sub

    Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)

    Dim s As String, I As Long, R As Long

    On Error GoTo Er

    If Data.GetFormat(vbCFFiles) Then

    For I = 1 To Data.Files.Count

    s = s & Data.Files(I)

    Next I

    End If

    If s = "" Then Effect = 0: Exit Sub

    If LCase(Mid(s, InStrRev(s, ".") + 1)) <> "xls" Then Exit Sub

    ShellExecute hWnd, "", s, "", "", vbNormalFocus

    Do

    DoEvents

    Loop While GetActiveWindow() = hWnd

    For I = 0 To 9

    With Text1(I)

    .LinkMode = 0

    .LinkTopic = "Excel|Sheet1"

    .LinkItem = "R" & I + 1 & "C1"

    .LinkMode = 1

    End With

    Next

    MsgBox "已連結上 " & s

    Exit Sub

    Er:

    MsgBox Error

    End Sub

    2008-12-01 12:10:11 補充:

    你的表單上放10個TextBox[Text1(0)~Text1(9)],程式貼上後直接執行,然後在檔案總管或我的電腦按住你要連結的.xls拖曳到表單中就能連接.

    那些.dll是API 函數是Windows開放給程設者使用的.

Still have questions? Get your answers by asking now.