Menu
  • HOME
  • TAGS

How to select rows from a DataTable where a Column value is within a List?

asp.net,.net,vb.net,linq,datatable

In the past, I've done this sort of like this: Dim item = From r as DataRow in dtCodes.Rows Where lstCodes.contains(r.Item("Codes")) Select r Does that work?...

Gridview items not populating correctly

asp.net,vb.net

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...

.NET use IIF to assign value to different variables

.net,vb.net,conditional,variable-assignment,iif

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...

Getting the updated XML element based on variable values in VB.Net

xml,vb.net

If I understand you correctly, you can use .Element() method to find first child having element name equals certain name, for example : Dim elementName As String = "TestDB" connectionString = root.Element(elementName).Value Dotnetfiddle Demo...

how can i use parameters to avoid sql attacks

sql,vb.net

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...

Connecting to database using Windows Athentication

sql-server,vb.net,authentication,connection-string

You need to add Integrated Security=SSPI and remove username and password from the connection string. Dim ConnectionString As String = "Data Source=Server;Initial Catalog=m2mdata02;Integrated Security=SSPI;" ...

How to text before a gridcolumn datafield

asp.net,vb.net

I would recommend you to use GridTemplateColumn as : <telerik:GridTemplateColumn DataField="Call" DataType="System.Int32" FilterControlAltText="Filter Call column" HeaderText="" SortExpression="Call" UniqueName="Call"> <ItemTemplate> <a href="http://twilio.liquidus.net/handleincomingcall.ashx?call=<%# Eval("Call") %>" title="Get call"><asp:Label ID="lblCallId" runat="server" Text='<%# Eval("Call") %>'></asp:Label></a> </ItemTemplate> </telerik:GridTemplateColumn> ...

Filter bind source

c#,regex,vb.net

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...

VBMath using / equivalent in C# [closed]

c#,vb.net

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.

Hashing Password in ASP.NET and Resolving it In SQL Procedure

asp.net,vb.net,stored-procedures,hash,password-protection

A very simple aproach is to use a MD5 hash. public class MD5 { public static string Hash(string message) { // step 1, calculate MD5 hash from input System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create(); byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(message); byte[] hash = md5.ComputeHash(inputBytes); // step 2, convert byte array to hex string StringBuilder...

Vb.NET Architecture with Option Strict On

vb.net,strict

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...

VB.net: How to define a namespace where the first segment is NOT the file name?

vb.net

Remove the Root namespace from the project properties: ...

Multiple Alignments Inside Button

vb.net,button

You can create labels and set the parents of the label to be that button *Remember that the position of the label is now relative to the button Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load lblA.text="A" lblA.Parent=Button1 lblA.Location = New Size(0,0) lblB.Text = "B" lblB.Parent = Button1...

Get List of Elements in Tree with specific Field Value

vb.net,linq,properties,interface

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 =...

Append second datatable to existing datatable

sql,asp.net,vb.net

Assuming the two have the same schema, try this. Replace: lbProduct.DataSource = myDataTable lbProduct.DataTextField = "product_name" lbProduct.DataValueField = "product_id" lbProduct.DataBind() With this: CType(lbProduct.DataSource,DataTable).Merge(myDataTable); lbProduct.DataBind(); ...

If and only if in vb.net 4?

vb.net,if-statement,.net-4.0

In the second? example here(VS2015RC) Microsoft is using IIF to illustrate how the If operator is short circuited, so I think IIF is still with us.

Use String to find my.resources

vb.net

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...

Getting Multi Rows in Database and transferring it in a multiline textbox in VB.net WinForms

database,vb.net,winforms,textbox

I don't think you need to first query the db to get the count of records before then going back to the db to get the phonenumbers, you could just do this: mycom.CommandText = "SELECT Cellphone FROM tbl_applicant where Gender='Female';" myr = mycom.ExecuteReader While myr.Read() TextBox1.Text = TextBox1.Text & myr(0)...

How can I run “query session” using vb.net?

vb.net,visual-studio-2013,cmd

It seems to be a permission problem. You need to pass a user name and a password of an administrator user to your command ..... process.StartInfo.UserName = "yourAdminUser" process.StartInfo.Password = GetPassword() ..... Public Function GetPassword() as String Dim ss = new SecureString() ss.AppendChar("p") ss.AppendChar("a") ss.AppendChar("s") ss.AppendChar("s") return ss End Function...

How do I use VB.NET to send an email from an Outlook account?

vb.net,email

change the smtpserver from smtp.outlook.com to smtp-mail.outlook.com web.config settings <mailSettings> <smtp deliveryMethod="Network" from="[email protected]"> <network host="smtp-mail.outlook.com" userName="[email protected]" password="passwordhere" port="587" enableSsl="true"/> </smtp> </mailSettings> ...

Database only adds (x) amount of rows before error system resources exceeded

database,vb.net,ms-access

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...

Order LINQ query elements by a collection of numbers

.net,vb.net,linq,compare,compareto

Change: OrderBy(Function(x) x.index.CompareTo(lineNumbers(x.index))) To: OrderBy(Function(x) lineNumbers.ToList().IndexOf(x.index)) Alternatively, if you changed the type of the lineNumbers parameter from IEnumerable(Of Integer) to List(Of Integer), then you wouldn't need to call the ToList method. Although, I have to say, while I love LINQ because it makes the code so much more readable, this...

How to create a top-level folder in my Outlook using vb.net - VB.NET, Outlook 2013

vb.net,outlook,outlook-addin

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...

Check if VB.net dataset table exists

vb.net,if-statement,dataset

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...

Adding contents of a DataViewGrid to access - VB

vb.net,gridview,datagridview

You keep adding parameters over and over. Try clearing them at the beginning of the loop: For x As Integer = 1 To DataGridView1.Rows.Count - 1 cmd.Parameters.Clear() and avoid empty Try-Catches. You are ignoring problems in your code when you do that. For one thing, the "Age" field probably shouldn't...

How to get value from dataGridView which is imported from .xls file

asp.net,vb.net,gridview,datagridview

I inspired with your answer. So, here is my resolution : For data As Integer = 0 To InvestorGridView.Rows.Count - 1 Response.Wri‌​te(InvestorGridView.Rows(data).Cells(0).Text) Response.Wri‌​te(InvestorGridView.Rows(data).Cells(1).Text) Response.Wri‌​te(InvestorGridView.Rows(data).Cells(2).Text) Next ...

Automapper AfterMap function initialising classes

.net,vb.net,automapper

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.

How do I display an Icon on the Taskbar but not on the form itself?

vb.net,winforms,visual-studio

I have found a workaround. If you do Me.ShowIcon = False after the form is loaded, then it will display in the taskbar, but not on the program. One way to do this is to have a timer enabled/begin as soon as form load ends, and then on tick, do...

Syntax error in Insert query in Mysql in VB.Net

mysql,vb.net

you miss the closing parenthesis for the values list: Dim cmd1 As New OdbcCommand("insert into party values('" + pcode_txt.Text + "','" + Trim(UCase(name_txt.Text)) + "','" + Trim(UCase(addr_txt.Text)) + "','" + phone_txt.Text + "','" + combo_route.SelectedItem + "','" + combo_area.SelectedItem + "')", con) My answer is perfectly fit to your question...

Call controls inside view(xaml file) in viewmodel

wpf,vb.net,mvvm

Accessing your view components from inside your viewmodel is not the way to do things in MVVM. Because it is specifically not designed to work this way, you will have to go out of your way to make it work. You should probably investigate how to accomplish your goals using...

VB.Net DateTime conversion

jquery,vb.net,datetime

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...

Outlook 2013 Cannot create ActiveX component from ASP.NET Application

asp.net,vb.net,outlook,office-interop

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.

Delete file after “x” second after creation

vb.net,function

You must handle the timed event in a handler for the Timer's Tick Event (or Elapsed if using System.Timers.Timer): Private m_strTest As String = String.Empty Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click m_strTest = Application.StartupPath & "\" + tte4 Timer1.Enabled = True End Sub If using System.Forms.Timer...

Filtering Last Duplicate Occurrence In A Datatable

c#,vb.net

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....

Scraping Javascript webpage (script error occurred)

javascript,html,vb.net,web,scrape

You can use WebBrowser.ScriptErrorsSuppressed = true; property. Details: https://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.scripterrorssuppressed%28v=vs.110%29.aspx...

Using Linq with VB.NET

vb.net,linq

You're still using c# syntax for your lambda expression. See http://msdn.microsoft.com/en-us/library/bb531253.aspx for details of Lambda expressions in vb. In your case its as simple as val1 = val1.OrderBy(Function (c) c ).ToArray ...

Get XML node value when previous node value conditions are true (without looping)

xml,vb.net,linq-to-xml

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>" + "...

Formatting a drive in Visual Basic?

vb.net,format,drive

The problem is that Process.Start does not take command line arguments in the first parameter. Use the overload that allows command line arguments. For example: Process.Start("format.com", "H:"); ...

vb.NET Screen Location

vb.net,location,screen

As I mentioned on another site, if I'm understanding you correctly then something like this should do as you want: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim number = 1 For Each scr In Screen.AllScreens.OrderBy(Function(s) s.Bounds.Left) Dim f As New Form With {.Text = number.ToString(), .StartPosition...

Want to create function validating textbox with letters only

vb.net,winforms,visual-studio-2010

Here's a method that will detect only letters but there is far more to your problem than just that. Private Function IsAllAlpha(text As String) As Boolean Return text.All(Function(ch) Char.IsLetter(ch)) End Function Notice that I have written a Function rather then a Sub. Your original method is poorly written. What you...

How to count value from string in for loop in vb?

vb.net,string

You can use LinQ to count the number of brackets: Dim Count = (From s In i Select s Where s = "{").Count And you should rename i to something sensible in my opinion. For when you have just any delimiter in your text and want to count single numbers...

How to make existing forms deriven from a base form in VB.net

vb.net,inheritance

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...

How to make a programs icon in the task bar change based on something like time? [duplicate]

c#,.net,vb.net,visual-studio-2013

You could to this at start (take Title out of the XAML) this.Title = DateTime.Now.ToString(); But a dynamic ticking clock in the task bar would not be easy ...

How do I get Visual Studio 2012 to generate code from a windows form design?

vb.net,winforms,visual-studio-2012

Forms comes as partial class meaning the code is separated in two files. The "empty" code you shown is from "mcastmain.vb" (if the file is named as the class). With that one there is a (probably hidden) file "mcastmain.designer.vb" file which contains the generated code by the designer ; and...

VB.NET get average from a range of values from a sortedlist (sortedlist.average)

vb.net,average,sortedlist

I think you can filter the list first and then get the average: MeasuredValues _ .Where(Function(measure) cDate(measure.Key) >= dateFrom And cDate(measure.Key) <= dateTo) _ .Average(Function(measure) measure.Value) REGARDING UPDATE 2: If I understand the new issue corrently, you're getting an error on the Average if Where returns no elements. I know...

Improve DataGridView rows managing

.net,vb.net,winforms,datagridview,datatable

what can I do to manage a DataSource instead of directlly manage the rows collection of the control A Class and a collection are pretty easy to implement as a DataSource and will also it will be pretty easy to modify your MoveUp/Dn methods for it. Class DGVItem Public Property...

Select contents of parenthesis in substring (VB.NET)

vb.net,string-parsing

This is what regular expressions are ideal for, although this is a fairly basic match for them: Dim str as String = "Serial Port Name (COM 1)" Dim inbrackets as String = Regex.Match(str, "\((.*)\)").Groups(1).Value This expression looks for parentheses - the \( and \) - with any number of characters...

Generic Interface missing implementation

vb.net,interface,implements,generic-interface

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...

ZipEntry() and converting persian filenames

vb.net,persian,sharpziplib

Try setting IsUnicodeText to true: 'VB.NET Dim newEntry = New ZipEntry(entryName) With { _ Key .DateTime = DateTime.Now, _ Key .Size = size, _ Key .IsUnicodeText = True _ } //C# var newEntry = new ZipEntry(entryName) { DateTime = DateTime.Now, Size = size, IsUnicodeText = true }; ...

check if a list contains all the element in an array using linq

vb.net,linq

You can use Enumerable.All: dim linqMeddata = From m In medicineDataList Where keys.All(Function(k) m.MedicineData.Contains(k)) Order By m.MedicineName Ascending Select m ...

vb.net AES decryption returns “data is incomplete block”

vb.net,encryption,cryptography,aes

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...

Where to store an mp4 file in my project?

.net,vb.net,visual-studio,mp4

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...

Simple explanation about loading files into memory

vb.net,visual-studio-2010,memory-management

When they refer to reading something "into memory" it is simply a way of saying that you are reading it and storing it in a variable (which stores it in memory). Use ReadAllLines to read the entire file into memory: Dim readText() As String = File.ReadAllLines(path) See File.ReadAllLines Method (String)...

Arraylist with Multi Dimentional for loops

vb.net,multidimensional-array,arraylist

Preliminaries: You should turn on Option Strict, and consider using a List(of String) in place of the ArrayList. Your second line, splits the string by "," into Sequence, so there is no need to split it again - you get the error because they cant be split further (and you...

When executing stored procedures in VB.NET/SQL, are we supposed to add “EXEC” or not?

sql-server,vb.net,stored-procedures

No. System.Data.CommandType.StoredProcedure does it for you. It will be helpful: How to: Execute a Stored Procedure that Returns Rows See too: Using EXECUTE with Stored Procedures You do not have to specify the EXECUTE keyword when you execute stored procedures when the statement is the first one in a batch....

Emulate copy-paste from Keyboard wedge application in VB.net

vb.net,sendkeys,keyboard-wedge

With SendKeys, the control key is ^. Then any additional keys can follow. So copy would be: SendKeys.Send("^c") And paste: SendKeys.Send("^v") Instead of copying, you can just directly put it on the clipboard (like you suggested), like: My.Computer.Clipboard.SetText("This is a test string.")...

Removing Alert When Using DeleteFile API

vb.net,vba,api,delete

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.

Explain what problems could have this function (if any)

.net,vb.net,winapi,pinvoke,getlasterror

From the documentation of GetLastError: The Return Value section of the documentation for each function that sets the last-error code notes the conditions under which the function sets the last-error code. Most functions that set the thread's last-error code set it when they fail. However, some functions also set the...

How do I prevent MySQL Database Injection Attacks using vb.net?

mysql,.net,database,vb.net,sql-injection

MySQLCon.Open() Dim SQLADD As String = "INSERT INTO members(member,gamertag,role) VALUES(@memberToAdd, @memberGamingTag, @memberRole)" COMMAND = New MySqlCommand(SQLADD, MySQLCon) COMMAND.Parameters.AddWithValue("@memberToAdd", memberToAdd.Text) COMMAND.Parameters.AddWithValue("@memberGamingTag", membersGamertag.Text) COMMAND.Parameters.AddWithValue("@memberRole", membersRole.Text) COMMAND.ExecuteNonQuery() memberToAdd.Text = "" membersGamertag.Text = "" membersRole.Text = "" MySQLCon.Close() MySQLCon.Dispose() You don't need to use...

Iterating through Twitch Json

json,vb.net,iteration,twitch

"Chatters" is actually a Type in the root object. If you were to create classes, they would look like this: Public Class RootChatter Public Property _links As _Links Public Property chatter_count As Integer Public Property chatters As Chatters End Class Public Class _Links End Class Public Class Chatters Public Property...

SQL Server - User that last entered a record [closed]

sql-server,vb.net

Since you are using a predefined username and password in the connection string, your options are limited to the .NET side. Through the database you'll have access to what machine name the update/insert/delete was executed from, but NOT what user. SYSTEM_USER will always return the account specified in the connection...

How to execute four queries once and then check success or failure?

vb.net,windows,visual-studio-2010,ms-access

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...

How to get substring date (year) using vb.net?

vb.net

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,...

c# to vb using Sync Framework strange error

c#,sql-server,vb.net,microsoft-sync-framework,localdb

The C# code contains doubled backslashes in the connection strings, because that's needed to escape them in string literals (or using a verbatim string literal). In VB that's not needed as \ isn't an escape character (as far as I'm aware) so you shouldn't double them: Dim clientConn As SqlConnection...

Visual Basic Datagrid View change row colour

vb.net,datagridview,datagrid

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...

String with Empty Variables

vb.net,string

You can put them in a collection and use String.Join: Dim allStrings As String() = {Ten11, Ten12, Ten13, Ten14, ...} Dim notEmpty = From str In allStrings Where Not String.IsNullOrEmpty(str) Dim TenantList As String = String.Join(",", notEmpty) I'm using LINQ to filter out the empty strings, so you need Imports...

Return index of word in string

arrays,vb.net,vbscript

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...

How to output a single file for each row of an excel file read in?

vb.net,excel,visual-studio-2010

Use StringBuilder.Clear before each row. For rr As Integer = 10 To rowct str.Clear() For cc As Integer = 1 To colct I would also suggest calling My.Computer.FileSystem.WriteAllText once per row since you are writing to the file on each columns....

Comparing arrays with numbers in vb.net

arrays,vb.net

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...

Get the method name that was passed through a lambda expression?

.net,vb.net,reflection,delegates,pinvoke

I would not do this. It would be simpler to pass a string var representing the error message you want to display or a portion thereof (like the function name). The "simplest" way would be to use an Expression Tree. For this, you would need to change the signature of...

How to pass all value of ListBox Control to a function?

vb.net,listbox

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...

VB LINQ - Take one random row from each group

vb.net,linq,random

One quick way to shuffle items is to sort by a "random" value - Guid.NewGuid() usually works well enough. Then just pull the first row from each group: Dim query = _ From rows As DataRow In surveyAnswerKeys.Rows _ Order By Guid.NewGuid() _ Group By questionSortKey = rows(answerGroup) _ Into...

Can't output Guid Hashcode

sql,vb.net,guid,hashcode

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:...

xsd:complexType after xsd:attribute declarations yields error

xml,vb.net,visual-studio-2010,xsd,xml-validation

Attribute declarations have to come after complexType, otherwise you'll get an error such as the following: [Error] try.xsd:26:40: s4s-elt-invalid-content.1: The content of '#AnonType_CResultsResStuff_EXT' is invalid. Element 'complexType' is invalid, misplaced, or occurs too often. Resolution: Move the attribute declarations below the xsd:complexType element (and remove the extra xsd:complexType). There's another...

XmlReader DataGridView flip column and rows

xml,vb.net,datagridview

My final code (working): Public Function FlipDataSet(my_DataSet As DataSet) As DataSet Dim ds As New DataSet() For Each dt As DataTable In my_DataSet.Tables Dim table As New DataTable() table.Columns.Add(New DataColumn("f")) table.Columns.Add(New DataColumn("v")) Dim r As DataRow For k As Integer = 0 To dt.Columns.Count - 1 r = table.NewRow() r(0)...

How to remove text from textbox/label without flicker

c#,.net,vb.net

I would advise to use another control rather than a TextBox. The way it repaints is just bad. You might have some luck when enabling double buffering on the control (something like here: How to prevent a Windows Forms TextBox from flickering on resize?), but I usually use a ListView...

String.compare returns true when strings aren't equal?

vb.net

You probably want String.Equals() and not String.Compare(). Compare is used to order things and not test for equality. What's happening is String.Compare is returning a non-zero number so the condition is being satisfied. The reason for that is because in VB "0" is False but any non-zero number evaluates to...

System.ArgumentOutOfRangeException in For loop due to entry deleted from database. Help fix it

database,vb.net,for-loop,indexing

Try going backwards - For i As Integer = (.Rows.Count - 1) to 0 Step -1. The issue is that you are deleting rows in the ReservationTableDataGridView as you try to iterate over them, thus changing the index. By going backwards you always have a valid index....

Custom drawing using System.Windows.Forms.BorderStyle?

c#,.net,vb.net,winforms,custom-controls

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,...

Convert date to string format

vb.net,converter

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...

Regex to check if string is alphanumeric separated by commas or a single alphanumeric string

regex,vb.net

^\d{1,2}[A-Z]?(?:,\d{1,2}[A-Z]?)*$ Try this.See demo. https://regex101.com/r/hI0qP0/25...

Retrieve full path of FTP file on drag & drop?

vb.net,ftp

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...

How to implement an interface defined in VB.net in VC++/CLI?

c++,vb.net,visual-c++

Looks like you just forgot get(). Proper syntax is: .h file: public ref class ThirdPartyInterfacingBar : Bar { public: property array<Quux^>^ Quuxes { virtual array<Quux^>^ get(); } }; .cpp file: array<Quux^>^ ThirdPartyInterfacingBar::Quuxes::get() { return delegateGetQuuxes(); } ...

Getting variable encryption results with VB.Net and DES

vb.net,encryption,des

You are setting TripleDES.Mode = CipherMode.ECB after you have called TripleDES.CreateEncryptor(), so the first encryption is using the default value of CipherMode.CBC. Since TripleDES is reused, after the first call to EncryptData its Mode is set correctly. Move TripleDES.Mode = CipherMode.ECB into New and it should work consistently....

VB.net DomainUpDown Infinite Selection

vb.net

That would be the .Wrap property: upDownControl.Wrap = True ...

How does .NET optimize methods that return a Structure value?

.net,vb.net

Just have a look at the generated machine code to see what happens. You first need to change an option to ensure the optimizer is enabled, Tools > Options > Debugging > General > untick the "Suppress JIT optimization" checkbox. Switch to the Release build. Set a breakpoint on the...

Why use And over AndAlso?

.net,vb.net

And is bitwise. AndAlso is boolean. Correctness wise, if we disregard short-circuting, And can always be used in all cases where AndAlso can be used (unless you get creative), but the other way round is not true. That is, And is a "universal" operator that will "do the right thing"...

Silverlight: Get first TextBox in DataTemplate

vb.net,silverlight,datatemplate,children

You are approaching the problem incorrectly. Accessing the DataTemplate and searching for a TextBox will get you nowhere. The template is only a blueprint, only when it is used somewhere (like for each item in your ItemsControl) its content is instantiated (once for each item). One of several possible solutions...

How to Write to a Certain Line in a File in VB

vb.net,file,file-access

I don't know if you can write to a specific line in a file, but if you need to you can write your lines to a List then write the list to a file 'Declare your list Dim lines As New List(Of String) For Each lineToWrite In YourLines If toInsert...

getting values from a selected item in a dropdownlist in a table cell that was dynamically created in a table in vb code behind

asp.net,vb.net

First when you add the DropDownList, give it an ID (use your cursor variable to avoid having a duplicate ID): EmployeeDDL.ID = "EmployeeDDL" & j.ToString() Secondly, since the DropDownList was dynamically added you need to use FindControl to get an instance of it. Also, make sure SelectedItem is not null/nothing....

Using psql options in npgsql

vb.net,postgresql,postgis,psql,npgsql

Npgsql is an simply a driver for interacting with the database, HTML formatting of results is completely out of its scope (unlike psql, which is a user-facing console app). Note that there wouldn't be any "universal" way to format the HTML in a way that would satisfy everyone. However, it...

Convert Double from String

asp.net,vb.net,visual-studio-2012,converter

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...