Posts

Donate

Webbrowser Control Imitate Internet Explorer Behavior

Image
Hi, Lately, I was given a task from a client if I can update my VB.NET crawler scripts with a webbrowser control to show/render images of the crawled website to the control. Normally, I used the control just to obtain the web page source and then parse the necessary information. By default, the settings of the webbrowser control is IE7. After doing some reseach, I stumbled upon a solution by Noseratio on IE Feature Control Hacks . The documentation for browser emulation can be found on MSDN: MSDN Browser Emulation . I uploaded a sample VB.NET application here: WebBrowser Control Similar to IE Browser Sample Result: Cheers! :)

List Running Computer Processes By Array Names Using LINQ In C# And VB.NET

Image
Here's a snippet on how to retrieve running process in your computer by array names using LINQ. C# Code 1 2 3 4 5 6 7 8 List<Process> procs = new List<Process>(); procs = new List< string >() { "firefox" , "iexplore" , "ssms" , "notepad++" , "chrome" } .SelectMany(o => Process.GetProcessesByName(o)).ToList(); foreach ( var item in procs) { Console.WriteLine(item.ProcessName); } VB.NET 1 2 3 4 5 6 Dim procs As IEnumerable( Of Process) = _ { "firefox" , "iexplore" , "ssms" , "notepad++" , "chrome" }.SelectMany(Function(proc) Process.GetProcessesByName(proc)) For Each p In procs Console.WriteLine(p.ProcessName) Next Console.ReadLine() Output

WPF DataGrid Row And Cells Extension Methods In VB.NET

Image
Below are extension methods in accessing WPF DataGrid Rows and Cells. These methods were based on existing C# methods and I converted them to VB.NET for VB programmers. WPF DataGrid Extension Methods: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 Option Explicit On Option Infer On Imports System.Runtime.CompilerServices Imports System.Windows.Controls.Primitives

Show Asterisk Triangle Shapes Using TSQL In SQL Server

Image
In programming, it's a common exercise to show triangle shapes using the asterisk character. Well, this can be achieved using TSQL as well. Script #1 DECLARE @Total1 INT DECLARE @ctrOuter1 INT DECLARE @ctrInner1 INT DECLARE @strPrint1 VARCHAR(100) SET @Total1 = 5 SET @ctrOuter1 = @Total1 SET @strPrint1 = '' WHILE @ctrOuter1 >= 1 --outer loop BEGIN SET @strPrint1 = '' SET @ctrInner1 = 0 WHILE @ctrInner1 <= (@Total1 - @ctrOuter1) BEGIN SET @strPrint1 = @strPrint1 + '*' SET @ctrInner1 = @ctrInner1 + 1 END PRINT @strPrint1 SET @strPrint1 = @strPrint1 + CHAR(13) SET @ctrOuter1 = @ctrOuter1 - 1 END Output: Script #2 DECLARE @Total INT DECLARE @ctrOuter INT

Databinding ASP.NET 4.5 GridView With jQuery And Ajax

Image
Hi, Here's a simple asp.net program that performs adding of data to GridView control through jQuery and ajax. On page load, perform databinding on dropdown list and gridview using server side and code behind. And on client side, that is a selection change occurs in dropdown list, perform binding by adding table rows and columns to GridView. Page Load (Load All Products): Selection Change (Load Specific Products): The sample code is available for download here: Databinding ASP.NET 4.5 GridView with jQuery and Ajax Code Cheers!

GeckoFX DocumentText Similar To Webbrowser Control Alternative (C#)

In this post GeckoFX DocumentText similar to Webbrowser , I presented a solution on how to retrieve the page source of a website. However, another solution was provided by a .NET guru using TextContent property: this .Document.GetElementsByTagName( "html" )[0].TextContent; Cheers!

How To Paint Or Set WPF DataGridCell Background Without Using IValueConverter

Here's how to paint WPF DatagridCell using extension methods without using IValueConverter. Extension Method: 1 2 3 4 5 6 7 8 9 10 11 12 Module DataGridExtensions < Extension() > Function GetRow ( ByVal grid As DataGrid, ByVal index As Integer ) As DataGridRow Dim row As DataGridRow = DirectCast (grid.ItemContainerGenerator.ContainerFromIndex(index), DataGridRow) If row Is Nothing Then grid.UpdateLayout() grid.ScrollIntoView(grid.Items(index)) row = DirectCast (grid.ItemContainerGenerator.ContainerFromIndex(index), DataGridRow) End If Return row End Function End Module MainWindow.xaml: 1 2 3 4 Dim firstRow As DataGridRow = grid1.GetRow( 0 ) 'grid1 is your DataGrid control Dim firstColumnInFirstRow As Controls.DataGridCell = DirectCast (grid1.Columns( 0 ).GetCellContent(firstRow).Parent, Controls.DataGridCell) 'set background firstColumnInFirstR

Split A String With Multiple Space As Delimiter Or Separator Using Regular Expression Or String.Split In C# and VB.NET

Given that you have a string that you want to split and the separator is two or more spaces. You can achieve using split() or Regex. VB.NET 1 2 3 4 5 6 7 8 Dim str As String = "Rule Name: WhosThere-176.44.28.203" Dim whosThereVar As String Dim whosThereString As String 'using split whosThereVar = str.Split( New String () { " " }, StringSplitOptions.RemoveEmptyEntries)( 1 ).Trim() 'using regex whosThereString = System.Text.RegularExpressions.Regex.Split(str, "\s{2,}" )( 1 ) C# 1 2 3 4 5 string str = "Rule Name: WhosThere-176.44.28.203" ; //using split string whosThereVar = str.Split( new string [] { " " }, StringSplitOptions.RemoveEmptyEntries)[ 1 ].Trim(); //using regex string whosThereString = System.Text.RegularExpressions.Regex.Split(str, @"\s{2,}" )[ 1 ];

Sorting A HashTable Object Using LINQ In C#.NET And VB.NET

Image
In .NET, you can't directly sort a Hashtable object. A tip on sorting a Hashtable object is to cast it to Dictionary then apply LINQ OrderBy() method to the Hashtable object. See examples below: VB.NET 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Private Sub SortHashTableKey () hash = New Hashtable() hash.Add( "B" , 1 ) hash.Add( "A" , 2 ) hash.Add( "C" , 3 ) Dim dict = hash.Cast( Of DictionaryEntry)() _ .ToDictionary(Function(d) d.Key, Function(d) d.Value) _ .OrderBy(Function(e) e.Key) Console.WriteLine( "Sort by Key" ) For Each item In dict.ToList() Console.WriteLine( String .Format( "{0}, {1}" , item.Key, item.Value)) Next Console.WriteLine(Environment.NewLine) End Sub Private Sub SortHashTableValue ()

Update ASP.NET Web Forms Label Control Value Using Continuous Mouse Down Click

Starting today, I'm going to contribute source code in vbforums.com( Visual Basic Forum ). The community helped me way back since VB 6.0 and VBA. And in turn, it's time to give back as an experienced member. :) Here's a an ASP.NET application I posted in ASP.NET code bank on how to update label values continuously on mouse hold. Update Label Value using jQuery/Javascript in ASP.NET Reference: Easily do a continuous action on mouse hold using javascript Cheers! :)

Donate