|
You have to Create the object like this:
Dim WithEvents Scriptlet1 as MyScriptlet
Set Scriptlet1 = CreateObject("MyScriptlet")
Sub Scriptlet1_namechanged
MsgBox("Value of name property changed")
End Sub
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi, I have a control that when it initializes in design mode it gives me an error. This is because the variable that it uses has not been initialized yet. I could just do error trapping but I would rather just detect if the program is running or if I am in design mode. Is there any way to do that?
Thanks,
Clint Singer
|
|
|
|
|
There is a property you can check that tells you.
If Ambient.UserMode Then
'We are in Run mode
Else
'We are in Design mode
End IF
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Hello,
I am trying to run a multithread sort of application. But the compiled code is giving problems. In gives memory access violation.
Pl. help.
In .frm file-->
Option Explicit
Const CTF_COINIT = &H8
Const CTF_INSIST = &H1
Const CTF_PROCESS_REF = &H4
Const CTF_THREAD_REF = &H2
Private Declare Function SHCreateThread Lib "shlwapi.dll" (ByVal pfnThreadProc As Long, pData As Any, ByVal dwFlags As Long, ByVal pfnCallback As Long) As Long
Private Sub Command1_Click()
Dim i As Long
SHCreateThread AddressOf NewThread, ByVal 0&, CTF_INSIST, ByVal 0&
' SHCreateThread AddressOf NewThread1, ByVal 0&, CTF_INSIST, ByVal 0&
' For i = 1 To 10000
' Me.Caption = i
' Next
End Sub
in .bas file-->
Option Explicit
Sub NewThread()
MsgBox "Messagebox, called from thread!"
End Sub
'Sub NewThread1()
' MsgBox "Messagebox, called from thread ONE!"
'End Sub
Regards,
~A.
|
|
|
|
|
Your code has so many problems I can't even begin to list them. Go here: www.powervb.com and buy the book. That's the only correct way to do threads in VB, period. Anything else is a hack, even if it seems to kinda work.
___________
Klaus
[www.vbbox.com]
|
|
|
|
|
I would like to know if someone could help me with an issue in VB. I've been searching (and searching!) for code that would allow me, in VB6, to span multiple CDs for my software installation. I am installing a suite of software products, hence the size is larger than 700Meg.
Thanks in Advance!
Rob
|
|
|
|
|
Have you tried using Install Shield or WISE?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I encounter problems when I try to print a text or a bitmap at the bottom of a page. My text or my bitmap are not printed entirely.
How can I tell to VB to print my text or my bitmap in the next page ?
Thks in advance.
Appstmd
|
|
|
|
|
Appstmd wrote:
How can I tell to VB to print my text or my bitmap in the next page ?
VB will do this automatically for text you print using the Printer.Print method, but it is best to do it yourself.
For text:
If Printer.CurrentY + Printer.TextHeight(text_to_print) > Printer.ScaleHeight Then
Printer.NewPage
End If
Printer.Print text_to_print
And for bitmaps:
Dim picBitmap as Picture
Set picBitmap = LoadPicture(filename_of_bitmap)
If Printer.CurrentY + (picBitmap.Height * Printer.TwipsPerPixelY) > Printer.ScaleHeight Then
Printer.NewPage
End If
Printer.PaintPicture ......
If you have the bitmap in a picturebox, just replace "picBitmap" in the above code with "Picture1.Picture"
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
hi,
I have a Word document Embedded in a VB Application (OLE).
I want to dispaly the ToolBars of Word in my VB Apllication.
How can I do this.
Please help...
Thanks,
FiroZ
|
|
|
|
|
I have a Word document Embedded in a VB Application (OLE).
How can I get rid of the dirty Border that comes around
the OLE document ???
Please help...
Thanks
FiroZ
|
|
|
|
|
I relise this is probably off topic but could someone explain to me what process control is. Say for instance I want to write a program to input\output with a electronic box someone is going to make up which would perform simple tasks through most probably the serial port, what language would I use. Someone suggested that you would need to write it in Process Control is this a language or what.
Even a relevent webpage would probably help heaps.
|
|
|
|
|
I think (and this might be widely inaccurate in your case) that process control is a general term for controlling hardware processes (like keeping the waterlevel in a tank between some predefined min and max).
I suppose you could use/extend the MSComm ActiveX control to handle the specific hardware you are using...
/moliate
|
|
|
|
|
I used to be able to do things like the following in the VB6 immediate window:
set doc = CreateObject("Microsoft.XMLDOM")
Does anyone know how I can do this VS.NET now that all the development environments have been combined?
Cheers,
Tom Archer
Author, Inside C#
|
|
|
|
|
Although I haven't tried setting a variable to an instance of a COM object, this seems to work (I've tried an Object type and set it to 1 and "asdf" successfully):
For some strange reason I'm thinking you can find your way to the command window so I'll skip that part In the command window type "immed" to switch to immediate mode (type ">cmd" to switch back to command mode). Once you're in immediate mode you can manipulate variables like you used to in VB6. This also seems to work in C#, but for some reason you have to set the variable twice in the command window for the assignment to stick....
Andy Gaskell, MCSD
|
|
|
|
|
Uh, no. The debugger is the same as C#'s, and doing something like that would imply edit-and-continue, which is not supported.
___________
Klaus
[www.vbbox.com]
|
|
|
|
|
Heres one for you.
How do you force a modal form to show up in the taskbar.
E.g.
You have a bog basic VB Form named Form1 and a Sub Main which looks like this.
Public Sub Main
Form1.Show vbModal
End Sub
The fact that the form is modal means that it doesn;t show up on the taskbar. I need it to show up on the task bar. Any ideas? API Welcome!
Cheers
Pete
|
|
|
|
|
If its the first form you are showing, then you dont need to make it modal. Just remove "vbModal" from your line.
--
David Wengier
|
|
|
|
|
This is obviously just a piece of test code. You dont think I'd leave a form named "Form1" in a real project do you?
Think of it as a puzzel. You have this information and need this result. What do you do?
Thanks for your answer.
Pete
|
|
|
|
|
Pete Bassett wrote:
You dont think I'd leave a form named "Form1" in a real project do you?
I've seen worse, and I dont like to assume anything about the knowledge people on forums have.
But, the question you asked, I answered correctly. For the answer to the question you should have asked, and meant, I shall post in a reply to this, as it is rather long.
There are probably other ways of doing this, but I use this method as it means I can just drop the module into my apps, and call the HookAttach method as necessary, whenever I want to give something a taskbar button
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Okay, long code:
Firstly, usage. Call the HookAttach function before loading and showing your form, as it catches the WM_CREATE message. Call HookDetach when you want to stop it catching forms. A good place for this is in the child form.
Now, the code. Put this in a standard module:
Option Explicit
Private Type CWPSTRUCT
lParam As Long
wParam As Long
message As Long
hwnd As Long
End Type
Private Type CREATESTRUCT
lpCreateParams As Long
hInstance As Long
hMenu As Long
hWndParent As Long
cy As Long
cx As Long
y As Long
x As Long
style As Long
lpszName As Long ' String
lpszClass As Long ' String
ExStyle As Long
End Type
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Const WH_CALLWNDPROC = 4
Private Const WS_EX_APPWINDOW = &H40000
Private Const WS_EX_TOOLWINDOW = &H80&
' VB5 & VB6 class names:
Private Const C_MDIFORMCLASS_IDE = "ThunderMDIForm"
Private Const C_MDIFORMCLASS_EXE = "ThunderRT6MDIForm"
Private Const C_MDIFORMCLASS5_IDE = "ThunderMDIForm"
Private Const C_MDIFORMCLASS5_EXE = "ThunderRT5MDIForm"
Private Const C_FORMCLASS_IDE_DC = "ThunderFormDC"
Private Const C_FORMCLASS_EXE_DC = "ThunderRT6FormDC"
Private Const C_FORMCLASS_IDE = "ThunderForm"
Private Const C_FORMCLASS_EXE = "ThunderRT6Form"
Private Const C_FORMCLASS5_IDE = "ThunderForm"
Private Const C_FORMCLASS5_EXE = "ThunderRT5Form"
Private m_hHook As Long
Private m_lHookWndProc As Long
<BR><BR>
Private Function Form_WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim lSetStyleEX As Long
' SPM - specific wnd proc for a form. Only called once for the WM_CREATE message.
Select Case Msg
Case WM_CREATE
Dim tCS As CREATESTRUCT
CopyMemory tCS, ByVal lParam, Len(tCS)
lSetStyleEX = GetWindowLong(hwnd, GWL_EXSTYLE)
lSetStyleEX = lSetStyleEX Or WS_EX_APPWINDOW
lSetStyleEX = lSetStyleEX And (Not WS_EX_TOOLWINDOW)
tCS.ExStyle = lSetStyleEX
CopyMemory ByVal lParam, tCS, Len(tCS)
SetWindowLong hwnd, GWL_WNDPROC, m_lHookWndProc
SetWindowLong hwnd, GWL_EXSTYLE, tCS.ExStyle
End Select
Form_WndProc = CallWindowProc(m_lHookWndProc, hwnd, Msg, wParam, lParam)
End Function
<BR><BR>
Private Function AppHook(ByVal idHook As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim CWP As CWPSTRUCT
Dim k As Long, aClass As String
If idHook >= 0 Then
CopyMemory CWP, ByVal lParam, Len(CWP)
Select Case CWP.message
Case WM_CREATE
aClass = Space$(128)
k = GetClassName(CWP.hwnd, ByVal aClass, 128)
aClass = Left$(aClass, k)
If IsIn(aClass, C_MDIFORMCLASS_IDE, C_MDIFORMCLASS_EXE, C_MDIFORMCLASS5_IDE, _
C_MDIFORMCLASS5_EXE, C_FORMCLASS_IDE_DC, C_FORMCLASS_EXE_DC, C_FORMCLASS_IDE, _
C_FORMCLASS_EXE, C_FORMCLASS5_IDE, C_FORMCLASS5_EXE) Then
m_lHookWndProc = SetWindowLong(CWP.hwnd, GWL_WNDPROC, AddressOf Form_WndProc)
End If
End Select
End If
AppHook = CallNextHookEx(m_hHook, idHook, wParam, ByVal lParam)
End Function
<BR><BR>
Private Function IsIn(ByVal vComp As Variant, ParamArray vTo() As Variant) As Boolean
Dim i As Long, iL As Long, iU As Long
On Error Resume Next
iU = UBound(vTo)
If Err.Number = 0 Then
iL = LBound(vTo)
For i = iL To iU
If vComp = vTo(i) Then
IsIn = True
Exit Function
End If
Next i
End If
End Function
<BR><BR>
Public Sub HookAttach()
m_hHook = SetWindowsHookEx(WH_CALLWNDPROC, AddressOf AppHook, App.hInstance, App.ThreadID)
End Sub
<BR><BR>
Public Sub HookDetach()
If m_hHook <> 0 Then
UnhookWindowsHookEx m_hHook
m_hHook = 0
End If
End Sub
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
|
Nice looking code there David. Unfortunatly it crashes pretty bad. Takes VB down with it. I put the Hook call before the Form1.Show vbmodal and the unhook call after.
It just shuts down vb.
Any other ideas? Maybe you could email me your working example?
Thanks again.
Pete
|
|
|
|
|
Interesting. Aside from adding the few API declerations I forgot (I am too used to win.tlb these days) it worked fine.
Email is on its way
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Fellow Programmers,
I am in the process of starting a new project on the development of condition based maintenance tool. I need some directions from any one of you out there. Here is what the project is all about.
The program should be able to sample data stream in real time from a running machnery and then compare data held in a database corresponding to different fault condition to the data stream in real time and them output the result in the form of the status of the machine.(i.e, whether the fault data corresponds to any portion of the continuous stream.
I will also appreciate codes on Neural Network (Backpropagation Algorithm or any ANN codes). I will strongly appreciate any response to enable me get started.
I can be reached at v_itulua@hotmail.com
v_itulua@hotmail.com
|
|
|
|
|