|
I figured everybody has to deal with crappy data. Maybe I should go to the source of the crappy data and fix that as well.
Good advice however.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
Based on some code I found I changed this code to take a picture from a webcam on a regular basis and stores the image an a folder.
This works! But I want to be able to minimize the form and put it in the system tray. When I do that I only get dark images.
Does anyone have a solution for this? I want the form in the system tray as people do other things on this laptop whilst the code takes pictures of a machine every x seconds.
This is the link to the code (in zip file) on OndeDrive:
Webcam VB .net code OneDrive[^]
Thanks for your input.
Frank
|
|
|
|
|
The component that does the capturing needs to paint the stream. Without painting the stream, there's only a black nothing to capture. Unfortunately, it only paints when Windows tells it to, and that's only when it is visible.
A cheap solution is to buy a Raspberry Pi and use that as a dedicated machine for capturing the images.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks Eddy.
Not the answer I wanted to hear, but I will look into a solution when a Pi.
Regards,
Frank
|
|
|
|
|
The below code sets the selected text in the RichTextBox to a protected link.
This works but I have an issue when entering text before the link; particularly
a space char. When I enter a space character before the link, the link loses
it's link state;
1. The color changes to normal text color.
2. The underline disappears.
3. I no longer receive the link click message.
4. It remains protected.
I can type other characters and do not lose the link state except when
the caret is on the space immediately preceding the link.
Test case with this text where link is the formatted link:
" abc link"
Hitting the spacebar anywhere between the 'c' and the 'l' causes the link to lose its state
Hitting any other char does not affect the state except when the char is next to the 'l' and
then it loses its state.
Anyone have an idea of why the link is losing it's attribute?
Thank you
Public Function SetSelectionCharFormat(ByVal hEdit As IntPtr, ByVal cf As CHARFORMAT2, _
Optional ByVal fmt As EMFormatMasks = EMFormatMasks.SCF_SELECTION Or EMFormatMasks.SCF_WORD) As Boolean
Dim bReturn As Boolean = False
' This is test code which overrides the input
cf.dwMask = (CFMMask.CFM_LINK Or CFMMask.CFM_PROTECTED) ' &h20 or &h10
cf.dwEffects = (CFEEffects.CFE_LINK Or CFEEffects.CFE_PROTECTED) ' &h20 or &h10
Try
Dim structPtr As IntPtr
' Allocate the memory for structure data
structPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cf))
' Copy structure data to memory ptr
Marshal.StructureToPtr(cf, structPtr, False)
' Return non-zero if passes; code from winctrl4.cpp
' fmt = the default (EMFormatMasks.SCF_SELECTION Or EMFormatMasks.SCF_WORD)
bReturn = (MyUtilsLib.WindowsAPI.SendMessage(hEdit, EMMessages.EM_SETCHARFORMAT, fmt, structPtr) <> 0)
' Free memory
Marshal.FreeHGlobal(structPtr)
#If DEBUG Then
If bReturn = False Then
Debug.WriteLine("SetSelectionCharFormat() failed")
End If
#End If
Catch ex As Exception
MsgBox(ex.Message())
End Try
Return bReturn
End Function
-- modified 23-Jan-19 15:38pm.
|
|
|
|
|
In a vb.net 2010 application, I have a page_load section of code where I would like to know add extra code unless I need it. Basically if the application is in development or test compile mode, I would like the application to point to a test url. If the application is in production mode, I would like the application to point to a production url.
From the page_load section of code, is there a way to knowwhat mode the applicaiton is in? If so, can yhou show me the code on how to accomplish this goal?
In addition, if the application is in production mode is there a way to not have the development or test logic be accessed by the application? If so, would you show me that logic?
|
|
|
|
|
|
What you supplied to me is a very good option that works! However on my application, there are the build options for:
1-Development,
2-Test, and
3-Production.
Based upon my build options, can I write code the will select only '1-Development' instead of placing #debug in the logic. Or having #debug stand for 1-development? If so, would you should me the code for this?
|
|
|
|
|
Sorry but I do not understand what you mean. The DEBUG define is automatically set by Visual Studio when you do a Debug build, and unset when you do a Release build. You need to decide what you want for a Test build and create the appropriate settings.
|
|
|
|
|
|
Hello !
On vb.net , I have a sub like this :
...
myobj.num=1
Myobj.vl=2
.....
I want to pass Myobj as a parameter when I call the sub. But the problem is that I want to call this same sub , one time when myobj is Type1 , and one time when myobj is Type2 ( Both type1 and Type2 are custom types that both have the fields .num and .vl).
How can I do this ?
Thank you !
|
|
|
|
|
|
The types type1 and type2 are totally different types , but both have the fields that I use on the sub.
|
|
|
|
|
In that case I would suggest you should have different subs. Or better still the types should expose their data content as Properties, which you can then set without needing to check which type it is.
|
|
|
|
|
Both of your "type1" and "type2" classes have fields in common. Ok, so those have to be broken out into something that is common between those two types, either an Interface implementation or a base class that they both inherit from.
You will then be able to pass your "type1" and "type2" class instances as either that interface or base class for the method to use. For example, an interface version would look something like:
Public Interface SomeInterface
Property SomeProperty As String
Property AnotherProperty As Int
End Interface
And both of your "types" would have to implement the interface:
Public Class Type1 Implements SomeInterface
...
End Class
Public Class Type2 Implements SomeInterface
...
End Class
When you define your method that has to accept instances of these two classes, you use the interface to define the parameter expected:
Public Sub MyMethod(ByVal parameter As SomeInterface)
End Sub
The method is saying "I need something that implements this interface". It's a contract where the method expects the object passed in as "parameter" to implement a know interface, guaranteeing the properties defined in the interface will be there in the object that is passed in.
When you go to call this method, you're saying this is an instance of Type1, but since it implements this interface, treat this object as this interface type, not as the Type1 class.
Dim myInstance As New Type1
...
MyMethod(myInstance)
|
|
|
|
|
Easy way is to put those details in their own class, and make that new class part of type1 and type2.
Public Class McBoatFace
Property Num As Integer
Property vl As String
End Class
Public Class Type1
Property Boat As McBoatFace
End Class
Public Class Type2
Property Boat As McBoatFace
End Class
Sub Marine(Boat As McBoatFace)
End Sub
A less easy, but cleaner way would be implementing the McBoatface-class as an interface, and to pass the interface to the sub. Another way to make it cleaner is by putting the Boat-property into a new Type0-class, and inherit Type1 and Type2 from it; makes the property appear in both classes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The types type1 and type2 are totally different types , but both have the fields that I use on the sub.
|
|
|
|
|
I suppose that there is a possible solution - but for this you should give more information about your issue ...
Perhaps you write something more about those 2 types and what is common to them.
In my opinion each of your types derive from Object and so you should be able to identify each type in your method ...
But ... as I wrote before ... more Info required ...
|
|
|
|
|
I am creating a tool to delete user profiles by age on all windows 7 and windows 10 devices on our domains. I have it working using this filter ("(objectClass=computer)") but want to refine that to only get windows 7 and windows 10 devices because my department manages desktops/laptops not servers. In order to make the tool more efficient and not attempt to connect to devices I don't have admin access to.
So I tried this filter... mySearcher.Filter = "(&(objectClass=computer)(operatingSystemVersion=*server*))" my thought was to do something like this if OS IsNot Windows Server 2012 or Windows Server 2008 then do something.
I loaded the operatingSystem property but can't get it to display. I have tried it in the datagridview and when that didn't work I just tried to do a consolewriteline and that didn't work either. I want to test my concept before adding the code to use WMI to delete profiles by just displaying the hostname and OS version to make sure it is pulling the information from AD and not giving me servers. Can someone help? Here is the code(I am just working with the v06 domain at the moment):
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.PropertiesToLoad.Add("dNSHostName")
mySearcher.PropertiesToLoad.Add("operatingSystem")
mySearcher.PropertiesToLoad.Add("operatingSystemVersion")
mySearcher.Filter = "(&(objectClass=computer)(operatingSystem=*server*))" '("(objectClass=computer)")
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
Select Case dMain
Case "v06"
Try
hostName = GetProperty(resEnt, "dNSHostName")
OSystem = GetProperty(resEnt, "operatingSystem")
Dim result1 As Net.NetworkInformation.PingReply = ping.Send(hostName, 1000)
If result1.Status = Net.NetworkInformation.IPStatus.Success Then
Dim row2 As String() = New String() {hostName, "N/A", OSystem}
dgvLocal.Rows.Add(row2)
Else
My.Computer.FileSystem.WriteAllText("C:\ExodusErrorLog.txt", hostName & " - Device is not pingable!" & vbCrLf & vbCrLf, True)
End If
Catch ex As Exception
My.Computer.FileSystem.WriteAllText("C:\ExodusErrorLog.txt", hostName & " - " & ex.Message & vbCrLf & vbCrLf, True)
End Try
Case "v07.med.va.gov"
End Select
Next
modified 25-Dec-18 13:32pm.
|
|
|
|
|
Here's an alternative to the solution you seek; get a full list of all the PC's, and then use LINQ to query out the ones that are servers. You may also get a better query from a network-admin; it is querying the AD after all.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Learning Threading, Invoke, Delegate and MethodInvoker ...
0) I use Visual Basic 2017.
1) I can press Button1 or Button2 randomly: works!
2) After the first round I can only press Button2. Button1 no longer works!
3) Who can indicate IN THE CODE where the error is?
4) I search for information everywhere on the internet, but what exactly Invoke, Delegate and MethodInvoker do, is not completely clear to me …
5) Thank you …
Public Class Form1
Dim Number1 As Integer
Dim Number2 As Integer
Dim Thread1 As System.Threading.Thread
Dim Thread2 As System.Threading.Thread
Private Delegate Sub UpdateLabel1Delegate(ByVal Number1 As Integer)
Private Delegate Sub UpdateLabel2Delegate(ByVal Number2 As Integer)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Thread1 = New System.Threading.Thread(AddressOf CountUp)
Thread1.Start()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Thread2 = New System.Threading.Thread(AddressOf CountDown)
Thread2.Start()
End Sub
Private Sub CountUp()
Do Until Number1 = 1000
Number1 = Number1 + 1
UpdateLabel1Text(Number1)
Loop
End Sub
Private Sub CountDown()
Number2 = 1000
Do Until Number2 = 0
Number2 = Number2 - 1
UpdateLabel2Text(Number2)
Loop
End Sub
Private Sub UpdateLabel1Text(ByVal Number1 As Integer)
If Label1.InvokeRequired Then
Me.BeginInvoke(New UpdateLabel1Delegate(AddressOf UpdateLabel1Text), Number1)
Else
Label1.Text = Number1
Me.Refresh()
End If
End Sub
Private Sub UpdateLabel2Text(ByVal Number2 As Integer)
If Label2.InvokeRequired Then
Me.BeginInvoke(New UpdateLabel2Delegate(AddressOf UpdateLabel2Text), Number2)
Else
Label2.Text = Number2
Me.Refresh()
End If
End Sub
End Class
|
|
|
|
|
You're initializing the number in one sub, but not the other.
Private Sub CountUp()
Number1 = 0
Do Until Number1 = 1000
Number1 = Number1 + 1
UpdateLabel1Text(Number1)
Loop
End Sub Enjoy the festivities and keep on learning, you're doing well
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks Eddy!
Very, very stupid of me !!
Eric
|
|
|
|
|
Member 11112814 wrote: Very, very stupid of me !! It's not, we all have those moments; you're searching for an error, and there clearly is none. I wasn't searching for one, just looking for the difference that you told me would be there.
It was a good formulated question with description of expected and actual results.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
My final assigment is about client server using timer. if client and server are connected with 30 minute then communication between clienrt and server will be disconnect. but i couldnt find timer function on internet. i have finished with client serverbut not yet to part using timer. if u can help me, please reply me as soon as possible.
Thank You.
modified 22-Dec-18 22:18pm.
|
|
|
|