|
One more in VB.Net:
http://www.lvr.com/hidpage.htm#MyExampleCode
http://www.lvr.com/files/hidclass.zip
|
|
|
|
|
Greetings All,
I am having trouble with a concept in VB.NET. I am trying to write and accessor property in a form so that I can change the text of a textbox from a subroutine in a class that I have written. However I cannot seem to get to the accessor property for the form within the class. Is this not possible? Here is the code for the property and the class. The class is instantiated in the form.
Form Code
Imports System.Threading
Public Class Form1
Inherits System.Windows.Forms.Form
Dim i As Integer
Dim clock As New Ticker
Dim cb As New TimerCallback(AddressOf clock.Tik)
Dim timer As Timer
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend Shared WithEvents txt1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(8, 4)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(106, 44)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Start Timer"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(120, 4)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(106, 44)
Me.Button2.TabIndex = 2
Me.Button2.Text = "Stop Timer"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(14, 56)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(208, 20)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(242, 87)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
timer = New Timer(cb, Nothing, 0, 1000)
End Sub
Public Property setText() As String
Set(ByVal Value As String)
TextBox1.Text = Value
End Set
Get
Return TextBox1.Text
End Get
End Property
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
timer.Dispose()
txt1.Text = "Timer Disposed"
End Sub
End Class
Class Code
Imports HWINTERFACELib
Public Class Ticker
Dim i As Integer
'Dim hw As New HwinterfaceClass
Public Sub Tik(ByVal obj As Object)
i += 1
'hw.OutPort(&H400, 62)
Form1.setText = i.ToString ' <--- doesn't work?
End Sub
End Class
Thanks in advance
|
|
|
|
|
Hi! I don´t think you have access to the form that class. From the top of my head i see a way (there are others i'm sure):
Use delegates. When you create the object from class ticker pass it a reference to the function setText.This reference can be used to initialize your delegate. If the object will execute in another thread (other than the UI thread) it's better to use also Me.Invoke(...);
Never say never
|
|
|
|
|
I'm trying to create a IMAP client and can't seperate my attachments from my message body- can anyone please help?
|
|
|
|
|
Hi guys im having problems playing videos mpeg files
basically im using mci sound to do this. At the moment I can play mp3, wav and other audio types but.. Im abit stuck on playing videos...I need help on how this is dun if anyone can give me a small example that would be great
Thank you doh:
|
|
|
|
|
Hello there
I have created an application with help file. When I press F1 it comes fine on every form . The problem is coming when I am opening a Dialog Form then on pressing F1 the help opens but not activated. infact form remains on top . to view the help window you need to click on the task bar to select the help file.
Any suggestions to get the focus on the help window directly.
I have tried to load the form by two ways but no difference
1. FormName.showDialog(Me) ' making dialog related to the main form
or
2. FormName.showDialog()
Best Regards
Rizwan Bashir
|
|
|
|
|
That's because .ShowDialog() shows the form as a modal dialog window. Modal means that your application cannot transfer the focus to any other window in the application (including your help window) until that modal window is closed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hmmmm.... Thanks for the support. I had the same opinion but was looking for another one..
Rizwan Bashir
|
|
|
|
|
how do i save pictures to Access database using VB6 .i used picturebox and "insert into" sql ,it saved in Access,but how i retrieve it back, pl help me
peace love unity respect
|
|
|
|
|
create a byte() field in Access Table and put it your image with:
open c:\myImg.jpg for binary access read #1
get #1, buffer()
close #1
connection.execute "insert into MyTable (MyField) VALUES (" & buffer() & ")"
|
|
|
|
|
hi!
How j can find the dominant color in a bitmap?
|
|
|
|
|
Create a histogram from the color of each pixel in the image.
Don't ask me for code, I don't have any. Your best bet would be Googling for "histogram algorithm vb.net".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
j find nothing in google
j create:
Dim cm As ColorMap
Dim cp As ColorPalette
Dim cpe As Color() = bmp.Palette.Entries
but cpe is empty
|
|
|
|
|
Hi All
I am working on ASP.NET (VB.NET) application.
I am creating some controls at runtime(A list of LinkButtons in a table).
On the click of a button i create all these controls. Now when i click on any of these controls they take me to another page. But when i click on back button and again press on any dynamic link button, it does not work properly. It seems that all these buttons have lost their event. Why? HELP!
Sumit Domyan
|
|
|
|
|
Sumit Domyan wrote:
I am working on ASP.NET (VB.NET) application.
Great! Now drop this question in the ASP.NET Forum[^] and you might get a better response. What you're asking really has nothing to do with VB.NET.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi!
I have an app that writes to a log file all the app's steps. I have several threads writing several times per second to the log file. The thing is that i have detected an exception with one of those writings, when i try to OPEN the log file. I use FileShare.Write so that there's no problem with writes form several threads at the same time(i thought).Did anybody experienced such a problem or is it my bug? I only write to the log in one function and i close the filestrems an the end.The code is:
Try
fs = File.Open(logPath & Format(Now(), "yyyyMMdd") & ".txt", FileMode.Append, FileAccess.Write, FileShare.Write)
fsWriter = New StreamWriter(fs)
fsWriter.WriteLine(Now & vbTab & entryString)
Catch ex As Exception
writeToErrorLog(ex.ToString)
Finally
If Not fsWriter Is Nothing Then
fsWriter.Close()
End If
If Not fs Is Nothing Then
fs.Close()
End If
End Try
Never say never
|
|
|
|
|
You just told us "It's broke". What's the exception message?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ops...Sorry :P
System.IO.IOException: The process cannot access the file "c:\myFile.txt" because it is being used by another process.
Never say never
|
|
|
|
|
I want to transform xml encoding "utf-8" to encoding "iso-8859-1" does anyone know how to accomplish this
|
|
|
|
|
hello
i wish to do a function
where with the press of a button new textbox will be created
the more the user press the button the more textbox will be created
can this function be done?
can kindly guide me at this?
thank yuo in advance
Gary
|
|
|
|
|
Hi!
In the button's handle declare a new textbox(withevents if you want or add the handlers you desire), initialize it and finally add the Control to the Form, or else the button won't show up.
Never say never
|
|
|
|
|
dear carlos,
thank you for ur reply
but i dont quite understand what you mean
can you please explain a little more detail?
sorry and thank you
Gary
|
|
|
|
|
Ok.sorry.I was on a hurry, i was leaving for my lunch hour :P
In the handler of the button you need to declare a new textBox object and do all the stuff i wrote.Here's a simple case:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim myTextBox as New TextBox
myTextBox.Location = (...)
myTextBox.Size = (...)
'If you need handlers
AddHandler myTextBox.(...), AddressOf myHandlerFunction
Me.Controls.Add(myTextBox)
(...)
End Sub
That's it then you can access the textBox through the Controls collection (Me.Controls(x)).If you would like to access the textbox in another way, and because you create them dinamically, maybe you should keep them in an arrayList or hashTable.
Sorry for the last post, i really hope i was clear this time.If not, ask again.
Never say never
|
|
|
|
|
thank you carlos
this is very clear
thank you for your guide and help
Gary
|
|
|
|
|
Hi,
I am using Webbrowser control to make a sort of custom web browser. I can browse any URLs with the Navigate method of the Webbrowser control. But when I use this method to open a saved URL shortcut, it doesn't open properly - graphics are not loaded. I saw that Webbrowser is opening not the URL contained in the URL shortcut but some other file in the Temporary Internet Files directory. I deleted temporary internet files, cleared history etc but still it seems the webbrowser generates the temporary file from the shortcut.
How can I make sure that the Navigate method opens the acutal URL contained in the shortcut ?
I hope what I ask is clear enough.
mecracked
|
|
|
|