p.kontalis
p.kontalis
Reputation Top 1%
Panos Kontalis
IT & Automation Engineer
18 Snippets  (42nd place)
Published
1 Channel
Created
5 Channels
Following
455 points  (69th place)
Reputation
Top 10% Publisher
Junior Code Generator
Serious Code Generator
Senior Code Generator
Junior Publisher
Serious Publisher
Senior Publisher
Junior Trend Maker
Serious Trend Maker
Junior Judge
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Master Autobiographer
Junior Snip2Coder
Junior Famous Coder
Senior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by p.kontalis

public by p.kontalis  1216  0  6  0

Replace Assembly.LoadWithPartialName with Assembly.Load

The Assembly.LoadWithPartialName has been deprecated. From now on you have to use Assembly.Load
'###Till .NET Framework 2.0 you can Load an assembly by its name
Dim FormsAssembly As Reflection.Assembly = Reflection.Assembly.LoadWithPartialName("System.Windows.Forms")

'###After .Net Framework 2.0 you have to use Assembly.Load
'###Therefore you have to give all the assembly information but the public token is not the same per pc
Dim FormsAssembly As Reflection.Assembly = Reflection.Assembly.Load("System.Windows.Forms, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 7a84f7ac56134e3a")

'###In order to bypass this wall either you retrieve it from the registry or you use the GetType(Form) for the retrieval.
Dim AssemblyLoadString As String = GetType(Form).AssemblyQualifiedName.ToString.Substring(GetType(Form).AssemblyQualifiedName.ToString.IndexOf(",") + 2)
Dim FormsAssembly As Reflection.Assembly = Reflection.Assembly.Load(AssemblyLoadString)                        
;

public by p.kontalis  2758  1  5  0

Numeric Validation on TextFields

Imports System.Globalization
Public Class Form 1

  Private Sub SheetFromWeight_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim YourPreferableCulture as String = "en-US"
    CultureInfo.DefaultThreadCurrentCulture = New CultureInfo(YourPreferableCulture)
    CultureInfo.DefaultThreadCurrentUICulture = New CultureInfo(YourPreferableCulture)
  End Sub
  
  Private Sub Numbers_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged,
                                                                               TextBox2.TextChanged,
                                                                               TextBox3.TextChanged
     If Not IsNumeric(sender.Text) Then sender.text = ""
     If sender.Text.contains(",") Then
          sender.text = sender.text.replace(",", ".")
          sender.select(sender.text.length, 0)
     End If
  End Sub                                  
End Class
;

public by p.kontalis  99034  2  5  0

VTiger Extraction Customers' Data by City

Extract from Vtiger Customers' List with address and to whom they have been assigned
SET @city = '[CITY NAME]'; #Replace [CITY NAME] with your preferable city name
SET @db_name='[DATABASE NAME]'; #Replace [DATABASE NAME] with your database name
SET @myquery = CONCAT('
SELECT	', @db_name, '.vtiger_account.accountid AS \'Company Code\',
		', @db_name, '.vtiger_account.accountname AS \'Company\', 
		', @db_name, '.vtiger_account.phone AS \'Phone 1\', 
		', @db_name, '.vtiger_account.otherphone AS \'Phone 2\', 
		', @db_name, '.vtiger_account.email1 AS \'Email 1\', 
		', @db_name, '.vtiger_account.email2 AS \'Email 2\', 
		', @db_name, '.vtiger_account.website AS \'Website\', 
		', @db_name, '.vtiger_account.fax AS \'Fax\',
		', @db_name, '.vtiger_accountbillads.bill_city AS \'City\',
		', @db_name, '.vtiger_accountbillads.bill_code AS \'TK\',
		', @db_name, '.vtiger_accountbillads.bill_country AS \'Country\',
		', @db_name, '.vtiger_accountbillads.bill_state AS \'State\',
		', @db_name, '.vtiger_accountbillads.bill_street AS \'Street\',
		', @db_name, '.vtiger_accountbillads.bill_pobox AS \'TK\', 
		', @db_name, '.vtiger_users.last_name AS \'Αssignment το\'
FROM ', @db_name, '.vtiger_account
INNER JOIN ', @db_name, '.vtiger_accountbillads 
ON ', @db_name, '.vtiger_account.accountid = ', @db_name, '.vtiger_accountbillads.accountaddressid
INNER JOIN ', @db_name, '.vtiger_crmentity
ON ', @db_name, '.vtiger_account.accountid = ', @db_name, '.vtiger_crmentity.crmid	
LEFT JOIN ', @db_name, '.vtiger_users
ON ', @db_name, '.vtiger_crmentity.smownerid = ', @db_name, '.vtiger_users.id
WHERE ', @db_name, '.vtiger_accountbillads.bill_city=@city
AND ', @db_name, '.vtiger_crmentity.setype=\'Accounts\' 
');
PREPARE stmt FROM @myquery;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
            
;

public by p.kontalis  3259  1  5  0

Retrieve System Characteristics

Windows System Information Function
Public Function RetrievePCInfo() As DataTable
    Dim DT As New DataTable
    DT.Columns.Add("Class")
    DT.Columns.Add("Name")
    DT.Columns.Add("Value")
    Dim search3 As New ManagementObjectSearcher("SELECT * FROM meta_class")
    Dim info3 As New ManagementObject
    For Each info3 In search3.Get
        Dim search4 As New ManagementObjectSearcher("SELECT * FROM " & info3("__CLASS").ToString)
        Dim Squerysearch4 As String = search4.Query.QueryString.ToString
        Dim info4 As New ManagementObject
        For Each info4 In search4.Get
            For Each Prop As PropertyData In info4.Properties
                DT.Rows.Add(info3("__CLASS").ToString, Prop.Name, Prop.Value)
            Next
        Next
    Next
    Return DT
End Function

' Beware this of code requires a large amount of RAM.
' Recommended to Extract all classes first and then for each class retieve the values.
' info class from motherboard is Win32_Bios
' info class from CPU is Win32_Prosessor
;

public by p.kontalis  3511  1  5  0

Hotkey for Application

Hotkey or Combination that can effect everywhere inside the application
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' Add the following line in order to enable the capability to capture the keyboard events before any other element in the form.
    Me.KeyPreview = True
End Sub

Private Sub Hotkeys_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    ' The Alt + P Hotkey raise the event Button1.Click
    If (e.Alt AndAlso (e.KeyCode = Keys.P)) Then RaiseEvent Button1.Click
End If
;