|
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.
|
|
|
|
|
|
thakn you for your reply
|
|
|
|
|
Unless you love getting spam emails, NEVER post your email address in a public forum. I suggest you edit your post and remove it now.
|
|
|
|
|
I'm creating an project which can show me the complete list of "Installed" software in my system and "Uninstalled" them please help me to find.
|
|
|
|
|
|
|
There is no "complete" list; not every application registers an uninstaller with Windows.
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 SQL code am using is
Private Sub Command8_Click()
Dim SQL As String
SQL = "SELECT tblVisit.PatientID, tblPatients.Firstname, tblPatients.Lastname" _
& "DateDiff('yyyy',[tblPatients]![Birthday],Now()) AS Age, tblVisit.[Date Visit]" _
& "tblVisit.Diagnosis" _
& "[First Name] & ' ' & [Last Name] AS [Prescriber Names] FROM tblPatients INNER JOIN (tblDoctor INNER JOIN tblVisit ON tblDoctor.DoctorID = tblVisit.DoctorID) ON tblPatients.PatientID = tblVisit.PatientID" _
& "WHERE [Firstname] = '" & Me.txtKeywords & "' "
Me.subClientList.Form.RecordSource = SQL
Me.subClientList.Form.Requery
End Sub
The error that is coming up is..
The error is runtime error '3075'
syntax error (missing operator) in query expression 'tblvist'.[DateVisit]tblVist.Diagnosis[First Name]& ' ' [Last Name]'
The
[First Name]& ' ' [Last Name]' are from a table prescribers and the
tblVist.Diagnosis is an attachment column in the table visit and the
tblvist'.[DateVisit]tblVist is a column of visit dates
|
|
|
|
|
I think you need a comma after each item.
|
|
|
|
|
Thanks alot for your input. Because of you. I managed to troubleshoot and I have got it working. thanks alot
|
|
|
|
|
You're using string concatenation to build the query. This alone is a bad idea as you are very vulnerable to making mistakes and you open the database up to being destroyed due to SQL Injection attacks.
Your code looks like this:
SQL = "SELECT tblVisit.PatientID, tblPatients.Firstname, tblPatients.Lastname" _
& "DateDiff('yyyy',[tblPatients]![Birthday],Now()) AS Age, tblVisit.[Date Visit]" _
& "tblVisit.Diagnosis" _
& "[First Name] & ' ' & [Last Name] AS [Prescriber Names] FROM tblPatients INNER JOIN (tblDoctor INNER JOIN tblVisit ON tblDoctor.DoctorID = tblVisit.DoctorID) ON tblPatients.PatientID = tblVisit.PatientID" _
& "WHERE [Firstname] = '" & Me.txtKeywords & "' "
This results in a query string that looks like this. Examine this query statement closely and you're going to find lots of problems. You're missing spaces between words and messed up the concatenation in places.
SELECT tblVisit.PatientID, tblPatients.Firstname, tblPatients.LastnameDateDiff('yyyy',[tblPatients]![Birthday],Now()) AS Age, tblVisit.[Date Visit]tblVisit.Diagnosis[First Name] & ' ' & [Last Name] AS [Prescriber Names] FROM tblPatients INNER JOIN (tblDoctor INNER JOIN tblVisit ON tblDoctor.DoctorID = tblVisit.DoctorID) ON tblPatients.PatientID = tblVisit.PatientIDWHERE [Firstname] = 'SqlInjectionAttack' "
Now, Google for "SQL Injection Attack" to find out why what you did was so wrong, then Goggle for "VB.NET SQL parameterized queries" to find out what to do about it.
|
|
|
|
|
Public Class Form1
Dim attempt As Integer
Private Sub BtnLogIn_Click(sender As Object, e As EventArgs) Handles BtnLogIn.Click
If CBUser.Text = "Mineomyn" And TBPass.Text = "lemsilog" Then
MsgBox("Log in successful!", MsgBoxStyle.Information)
TBPass.Clear()
GBAddons.Enabled = True
GBPizza.Enabled = True
RichTextBox1.Enabled = True
BtnCalculate.Enabled = True
BtnCompleteOrder.Enabled = True
BtnClearOrder.Enabled = True
TBAmount.Enabled = True
TBChange.Enabled = True
TBTotal.Enabled = True
BtnChange.Enabled = True
ElseIf CBUser.Text = "Lemsilog" And TBPass.Text = "lemsilog" Then
MsgBox("Log in successful!", MsgBoxStyle.Information)
TBPass.Clear()
GBAddons.Enabled = True
GBPizza.Enabled = True
RichTextBox1.Enabled = True
BtnCalculate.Enabled = True
BtnCompleteOrder.Enabled = True
BtnClearOrder.Enabled = True
TBAmount.Enabled = True
TBChange.Enabled = True
TBTotal.Enabled = True
BtnChange.Enabled = True
ElseIf CBUser.Text = "Lemzipon" And TBPass.Text = "lemsilog" Then
MsgBox("Log in successful!", MsgBoxStyle.Information)
TBPass.Clear()
GBAddons.Enabled = True
GBPizza.Enabled = True
RichTextBox1.Enabled = True
BtnCalculate.Enabled = True
BtnCompleteOrder.Enabled = True
BtnClearOrder.Enabled = True
TBAmount.Enabled = True
TBChange.Enabled = True
TBTotal.Enabled = True
BtnChange.Enabled = True
Else attempt = attempt + 1
End If
If attempt = 1 Then
MsgBox("Incorrect user or pass. Attempts left: 2", MsgBoxStyle.Exclamation)
TBPass.Clear()
GBAddons.Enabled = False
GBPizza.Enabled = False
RichTextBox1.Enabled = False
ElseIf attempt = 2 Then
MsgBox("Incorrect user or pass. Attempts left: 1", MsgBoxStyle.Exclamation)
TBPass.Clear()
GBAddons.Enabled = False
GBPizza.Enabled = False
RichTextBox1.Enabled = False
ElseIf attempt = 3 Then
MsgBox("Incorrect user or pass. You have reached maximum attempts to log in. Try again later.", MsgBoxStyle.Critical)
TBPass.Clear()
GBAddons.Enabled = False
GBPizza.Enabled = False
RichTextBox1.Enabled = False
BtnLogIn.Enabled = False
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GBPizza.Enabled = False
GBAddons.Enabled = False
RichTextBox1.Enabled = False
BtnCalculate.Enabled = False
BtnCompleteOrder.Enabled = False
BtnClearOrder.Enabled = False
TBAmount.Enabled = False
TBChange.Enabled = False
TBTotal.Enabled = False
BtnChange.Enabled = False
End Sub
Private Sub calculate()
Dim cost As Double
Dim order As String
If Radsmall.Checked Then
cost = Radsmall.Tag
order = "18 inch"
ElseIf Radmedium.Checked Then
cost = Radmedium.Tag
order = "24 inch"
Else
cost = Radlarge.Tag
order = "28 inch"
End If
If CB15Coke.Checked Then cost += CB15Coke.Tag
If CB1Coke.Checked Then cost += CB1Coke.Tag
If CBCrust.Checked Then cost += CBCrust.Tag
If CBextracheese.Checked Then cost += CBextracheese.Tag
If CBmushroom.Checked Then cost += CBmushroom.Tag
If CBsingledrink.Checked Then cost += CBsingledrink.Tag
TBTotal.Text = cost
Dim display As String = "You order a " & order
If ComboPizza.Text = "Pepperoni" Then display += " pepperoni pizza"
If ComboPizza.Text = "4 Cheese" Then display += " 4 cheese pizza"
If ComboPizza.Text = "All meat" Then display += " all meat pizza"
If ComboPizza.Text = "Hawaiian" Then display += " hawaiian pizza"
If ComboPizza.Text = "Classic Italian" Then display += " classic italian pizza"
If ComboPizza.Text = "New York Style" Then display += " New York style pizza"
If ComboPizza.Text = "Pure Beef" Then display += " pure beef pizza"
If CB15Coke.Checked Then display += " with 1.5L Coke"
If CB1Coke.Checked Then display += " with 1L Coke"
If CBCrust.Checked Then display += " with tuff crust"
If CBextracheese.Checked Then display += " with extra cheese"
If CBmushroom.Checked Then display += " with mushroom"
If CBsingledrink.Checked Then display += " with single drink"
Me.RichTextBox1.Text = display
End Sub
Private Sub BtnCalculate_Click(sender As Object, e As EventArgs) Handles BtnCalculate.Click
calculate()
End Sub
Private Sub BtnCancelOrder_Click(sender As Object, e As EventArgs) Handles BtnClearOrder.Click
TBAmount.Clear()
TBChange.Clear()
TBTotal.Clear()
Radlarge.Checked = False
Radmedium.Checked = False
Radsmall.Checked = False
CB15Coke.Checked = False
CB1Coke.Checked = False
CBCrust.Checked = False
CBextracheese.Checked = False
CBmushroom.Checked = False
CBsingledrink.Checked = False
ComboPizza.Text = ""
Me.RichTextBox1.Clear()
End Sub
Private Sub BtnChange_Click(sender As Object, e As EventArgs) Handles BtnChange.Click
TBChange.Text = Val(TBTotal.Text - TBAmount.Text)
End Sub
Private Sub BtnCompleteOrder_Click(sender As Object, e As EventArgs) Handles BtnCompleteOrder.Click
MsgBox("Order is complete. Your order will be delivered to you within 45 minutes. Thank you!")
End Sub
End Class
The "Calculate Order" button will do the total order. Then I have to manually put the amount on the "Amount Paid" textbox to get the change. Now, what I wanted to do is to assign the enter key so that I can just press enter after typing the amount and don't have to hover the mouse and click the "Amount Paid" button. I don't know the codes for it, and where should i put the codes, on the textbox or on the button? The accept button property is already used on my "Log in" button. Please help me. xD Thanks in advance!
|
|
|
|
|
|
Hello !
Is there any fast way to create a list of obj1(Integer,string) , where the first field is an integer from 1-2000 , and the second field is the same string. , so the list should be : (1,"a") , (2,"a"),(3,"a")........(2000,"a").
I know that with a for loop can I create this , but i'm asking if there's a more fast way.
Thank you !
|
|
|
|
|
Depends what you mean by "fast".
If you mean you want to save on typing, then try LINQ:
Dim myList As List(Of obj1) = Enumerable.Range(1, 2000).Select(Function(i) New obj1(i, "a")).ToList()
If you want the code to execute faster, then a For loop is probably your best bet. If you know the size of the list, then make sure you specify the initial capacity, to avoid having to reallocate the internal storage over and over again.
List<T>.Capacity Property (System.Collections.Generic) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|