The reason is that you are referring to the default instance in your second code snippet. Default instances are thread-specific so that second code snippet will create a new instance of the Form1 type rather then use the existing instance. Your Class1 needs a reference to the original instance of...

If the data dropped contains a UniformResourceLocator format, you can get the entire URL from that, for example: Private Sub Form1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop If e.Data.GetDataPresent("UniformResourceLocator") Then Dim URL As String = New IO.StreamReader(CType(e.Data.GetData("UniformResourceLocator"), IO.MemoryStream)).ReadToEnd End If End Sub It first checks to see if a...

Is it possible that your datagridview isn't loaded fully when you try to recolor the rows? Since you are setting the datasource, you should put your code that affects the grid after you can make sure that it is finished loading. The column widths change because it is not dependent...

Don't use string methods for this, use DateTime.TryParseExact: Dim str = "12/23/2015 12:00:00 AM" Dim dt As DateTime If DateTime.TryParseExact(str, "MM'/'dd'/'yyyy hh:mm:ss tt", Globalization.CultureInfo.InvariantCulture, Globalization.DateTimeStyles.None, dt) Then Dim yearOnly As String = dt.ToString("yy") ' 15 End If Update: with CultureInfo.InvariantCulture and this format you don't even need to use TryParseExact,...

Try this vb code behind, then comment out my test Private Sub BindGrid() Dim dt_SQL_Results As New DataTable '' Commenting out to use test data as I have no access to your database 'Dim da As SqlClient.SqlDataAdapter 'Dim strSQL2 As String 'Dim Response As String = "" 'strSQL2 = "SELECT...

Looking at your desired output it seems you want to get the index of word in your string. You can do this by splitting the string to array and then finding the item in an array using method Array.FindIndex: Dim animals = "cat, dog, bird" ' Split string to array...

You're passing the contents of a ListBox to a method that is just displaying them in a MsgBox(). There are two approaches you can do to accomplish what I think you're wanting. You can pass ListBox.Items to the method and iterate through each item concatenating them into a single String...

in the showDialog, you can set the parent form which causes the child to become modal: Public Class MainForm Dim frm2 As Form2 Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load frm2 = New Form2() Dim frmHandle As IntPtr = frm2.Handle frm2.Button1.Text = "test" System.Threading.ThreadPool.QueueUserWorkItem(New System.Threading.WaitCallback(AddressOf DoSomething), 0)...

The Designer creates property getters and setters for the images etc you add to Resources. So, for an image named dicedark1.jpg, it creates: Friend ReadOnly Property diceDark1() As System.Drawing.Bitmap Get Dim obj As Object = ResourceManager.GetObject("diceDark1", resourceCulture) Return CType(obj,System.Drawing.Bitmap) End Get End Property You can see these in Resources.Designer.vb. So...

You should change your code to something like the following. Note that Everything that returns an object like OleDbConnection, OleDbCommand, or OleDbDataReader is wrapped in a Using block. These objects all implement the IDisposable interface, which means they should be cleaned up as soon as you're done with them. Also...

You need to add Microsoft.VisualBasic as a reference to your Project. In your Project in the Solution Explorer right-click References and select "Add Reference". Search for "Microsoft.VisualBasic" in the Framework Tab.

just hold the color values in a config file simple text file will suffice. though you can use VisualStudio Resource file.. file will contain lines in each: item_enum_name item_type item_value for example: main_screen_bg_color Color Black company_logo URI \logos\logo1.jpg and so on.. just load the file parse it and use bind...

Top folders (root nodes in the navigation pane) are store. If you need to add a new store in the profile you can use the AddStoreEx method of the Namesapace class which adds a Personal Folders file (.pst) in the specified format to the current profile. See How to: Add...

If you don't know if the DataSet is initialized: If ds IsNot Nothing Then ' ... ' End If If you don't know if it contains four tables(zero based indices): If ds.Tables.Count >= 4 Then ' ... ' End If So the final super safe version is: If ds IsNot...

If you want to get results that reliably look like the BorderStyles on the machine you should make use of the methods of the ControlPaint object. For testing let's do it ouside of a Paint event: Panel somePanel = panel1; using (Graphics G = somePanel.CreateGraphics()) { G.FillRectangle(SystemBrushes.Window, new Rectangle(11, 11,...

There are a few basic ways of checking for a value in an integer array. The first is to manually search by looping through each value in the array, which may be what you want if you need to do complicated comparisons. Second is the .Contains() method. It is simpler...

Well, are you looking for a hashcode like this? "OZVV5TpP4U6wJthaCORZEQ" Then this answer might be useful: Guid g = Guid.NewGuid(); string GuidString = Convert.ToBase64String(g.ToByteArray()); GuidString = GuidString.Replace("=",""); GuidString = GuidString.Replace("+",""); Extracted from here. On the linked post there are many other useful answers. Please take a look! Other useful links:...

There are several SHFILEOPSTRUCT.fFlags options you'll want to consider. You are asking for FOF_NOCONFIRMATION, &H10. You probably want some more, like FOF_ALLOWUNDO, FOF_SILENT, FOF_NOERRORUI, it isn't clear from the question. Check the docs.

Despite all comments, I still lack understanding of your intentions. Therefore, the sample code below may not provide what you exactly want, but at least should give an idea how to employ cryptographic functions. Particularly, the most notable difference from your approach is that the encryption key and initialization vector...

No Office app (including Outlook) can run in a service (such as IIS). Your options are Extended MAPI (C++ or Delphi only), Redemption (which wraps Extended MAPI and can be accessed from any language, including C#), EWS (Exchange only) or straight SMTP.

There a number of other problems with the code (sql injection, sharing a connection among several commands), but here's a step in the right direction: Try conn.Open() cmdfoods.ExecuteNonQuery() cmdservices.ExecuteNonQuery() cmdreservations.ExecuteNonQuery() bill.ExecuteNonQuery() success = True Catch success = False Finally conn.Close() End Try A more-complete solution: Private Function save_to_data() Dim sql...

The result isn't wrong, it only has lower precision than you expected. Floating point numbers have a limited precision by design, and you simply can't expect to get a result that is more precise than its limit. You can use a Decimal to get higher precision. In this case it...

I think the only solution is create a new function and gradually migrate to it. Public Function ExecuteQueryReturnDS(ByVal cmdQuery As SqlCommand) As DataSet Try Dim ds As New DataSet Using sqlCon As New SqlConnection(connStr) cmdQuery.Connection = sqlCon Dim sqlAda As New SqlDataAdapter(cmdQuery) sqlAda.Fill(ds) End Using Return ds Catch ex As...

You need to indicate on the declaration of the Number function that it is the implementation of the Number Function defined in the Interface Interface IBuilder(Of T) Function Number(ByVal literal As String) As T End Interface Class BracketsBuilder Implements IBuilder(Of String) Public Function Number(number__1 As String) As String Implements IBuilder(Of...

Since you want to change existing forms to inherit another base class you need to change each form that you want to take effect and change what they inherit. Go to each of your forms designer code class. Inside towards the top you will see the inherits statment. Change what...

If i have understood it correctly you want to get all selected parents and all selected children. You could use a recursive method: Public ReadOnly Property checkedList As List(Of TreeSelectorAttributes) Get Return rootList.Where(Function(t) t.SelectedInTreeSelector). SelectMany(Function(root) GetSelectedChildren(root)). ToList() End Get End Property Function GetSelectedChildren(root As TreeSelectorAttributes, Optional includeRoot As Boolean =...

Your approach doesn't work because you are using ToString on a DataColumn which has no such overload like DateTime. That doesn't work anyway. The only way with the DataTable was if you'd add another string-column with the appropriate format in each row. You should instead use the DataGridViewColumn's DefaultCellStyle: InvestorGridView.Columns(1).DefaultCellStyle.Format...

The objects have values in them because they are called after Mapping.Map function is called and that's where actual object with values is passed and then AfterMap function is called and that's how it has the values in it.

You can use LINQ: DataTable nonDups = parsedDataset.Tables("Detail").AsEnumerable() .GroupBy(row => row.Field<string>("Authorization_ID")) .OrderBy(grp => grp.Key) .Select(grp => grp.Last()) .CopyToDataTable(); This selects the last row of each dup-group. If you want to order the group use grp.OrderBy....

You need to build your query to look like this: Name LIKE '%tom%' AND Name LIKE '%jack%' .... So take your input, split it up, project it to a new string and join them all together with AND: bndSourceGrid.Filter = string.Join(" AND ", cboName.Text .Split(' ') .Select(s => string.Format("Name LIKE...

System.Globalization.DateTimeFormatInfo.InvariantInfo doesn't contain format pattern dd-MM-yyyy(26-06-2015) From MSDN about InvariantCulture The InvariantCulture property can be used to persist data in a culture-independent format. This provides a known format that does not change For using invariant format in converting string to DateTime your string value must be formatted with one of...

Try going Project>"Project Name" Properties>Resources>Add Resource>Add Existing File This should add the file into your resources folder. You can then access any file by going My.Resources.Name_Of_Resource...

UPDATE Using an XDocument vs an XmlDocument, I believe this does what you're asking without using loops. This is dependent on the elements being in the order of <PhoneType> <PhonePrimaryYN> <PhoneNumber> string xml = "<?xml version=\"1.0\"?>" + "<Root>" + " <PhoneType dataType=\"string\">" + " <Value>CELL</Value>" + " </PhoneType>" + "...

What you're asking to do would have been possible in a language that supports pointer types (such as C/C++, or C# in unsafe mode) with dereferencing; VB.NET doesn't do that. The best you got to leverage is local variables, reference types, and (perhaps) ByRef. If it's a Class, its instantiation...

Try using Generics. Public Interface ICell(Of T) Property Value As T End Interface Public Class cell(Of T) Implements ICell(Of T) Public Property Value As T Implements ICell(Of T).Value Public id As Long Public Formula As String Public ix As Integer Public lev As Integer End Class Then both of these...