顯示具有 VB6 標籤的文章。 顯示所有文章
顯示具有 VB6 標籤的文章。 顯示所有文章

2013年2月21日 星期四

Iterate the items in the list

For i = 0 To frmTC.lstCH.ListCount - 1
            Exit For
Next

For loop

Dim j as Integer
For j = 1 To 8
      Exit For
Next

Create a message dialog

File name: frmMain.vb
frmMsgBox.Caption = "Test Item: " & m_arrMeasItem(Index).sName
  Load frmMsgBox
  frmMsgBox.Show vbModal
  If frmMsgBox.DialogResult = vbCancel Then
        Exit Sub
  End If


----
File name: frmMsgBox.vb
Option Explicit
Public DialogResult As VbMsgBoxResult

Private Sub cmdOK_Click()
    
    DialogResult = vbOK
    Unload Me
    
End Sub

Private Sub cmdStop_Click()
    
    DialogResult = vbCancel
    Unload Me
    
End Sub

vb6 goto

reference

SubroutineA:
Dim i As Integer
i = 8

    GoTo SubroutineA

2011年7月12日 星期二

if else in one line

method 1:

CheckIt = IIf(TestMe > 1000, "Large", "Small")

method 2:

i = 1
If i = 1 Then x = 3 : y = 3 Else x = 7 : y = 7

Reference

If ...else statement (Visual Basic)

do while continue

vb6 hasn't continue statement. If you want to use it, you can use goto to do the same thing.

do
if condition then goto continue_do
...
continue_do:
loop

Reference

2011年7月5日 星期二

capture a screenshot of a movie

2011年7月4日 星期一

浮點數轉小數第幾位

Dim dd As String
dd = CStr(Round(0.942, 4))

set active window

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetForegroundWindow& Lib "user32" (ByVal hwnd As Long)

then

Public Function ShowWindow(ByVal sWindowName As String)

Dim lWindowHandle As Long
lWindowHandle = FindWindow(vbNullString, Trim(sWindowName))

If lWindowHandle <> 0 Then
SetForegroundWindow (lWindowHandle)
Else
' Error Message
End If

End Function


sWindow name = the title bar of the programs window to be pulled forward.

It works, but inconsistently.

 

http://www.tek-tips.com/viewthread.cfm?qid=31084&page=42

save picturebox as bmp

SavePicture Picture1.Image, "C:\TEMP\BIGHEAD.BMP"

or

SavePicture Picture1.Picture, "C:\TEMP\BIGHEAD.BMP"  

http://social.msdn.microsoft.com/Forums/zh-TW/232/thread/73072d92-0ff3-40f9-81de-6094c8671acf/ 

execute application

Execute the excel file

GetObject("c:\test.xls").Parent.Visible = True

Reference

Execute a executable file 

Shell "notepad.exe"