FAQ Database Discussion Community


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

regex,vb.net
I have the following right now which works fine if the string is alphanumeric and separated by commas, but it doesn't work if I only have a single string. "^([a-zA-Z0-9]+,)+[a-zA-Z0-9]+$" Works for something like "1A,1B,1C", doesn't work on "1A" Sorry, I don't know much about regex and I only got...

Filtering Last Duplicate Occurrence In A Datatable

c#,vb.net
I am sorting a datable with the following code.. Dim sortedExtRecords1 As DataTable sortedExtRecords1 = parsedDataset.Tables("Detail").Clone Dim dvParsedDataset1 As New DataView(parsedDataset.Tables("Detail")) dvParsedDataset1.Sort = AuthorizatonConstants.Authorization_ID sortedExtRecords1 = dvParsedDataset1.ToTable("Detail") I can further filter the results to only return non duplicates and if there is duplicates I want the last record of the...

Arraylist with Multi Dimentional for loops

vb.net,multidimensional-array,arraylist
Friends I have a serious issue at present and Honestly I have no idea as to why this isn't working as expected. I am more a custom to C# than VB can anyone help with the following Code Example Please note that the String is passed from other classes and...

Set Label From Thread

vb.net,multithreading,winforms
Form1.vb Imports System.Threading Public Class Form1 Dim demoThread As Thread Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim Start As New Class1 Me.demoThread = New Thread( _ New ThreadStart(AddressOf Start.ThreadProcSafe)) Me.demoThread.Start() End Sub Delegate Sub SetTextCallback([text] As String) Public Sub SetText(ByVal [text] As String) ' InvokeRequired required...

Outlook 2013 Cannot create ActiveX component from ASP.NET Application

asp.net,vb.net,outlook,office-interop
I am trying to send email in VB.Net using outlook 2013. I tested as localhost in debug mode and everything is fine. I can send and read Outlook emails in vb.net. However, when I publish the web application and click the send button I get the following exception: System.Exception: Cannot...

WPF style info from external text file

wpf,vb.net,styles
Not sure if this is possible, but I have a WPF application that now has a requirement to be skinnable. Basically, this equates to several key colours and a couple of logos. Is there any way of grabbing the hex values for the colours in defined styles from an external...

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

mysql,.net,database,vb.net,sql-injection
I am using vb.net in Visual Basic 2010 and using Query to edit my Online MySQL Database from the application (WinForms). Here is a sample to insert a new user into the database: MySQLCon.Open() Dim SQLADD As String = "INSERT INTO members(member,gamertag,role) VALUES('" & memberToAdd.Text & "','" & membersGamertag.Text &...

Select contents of parenthesis in substring (VB.NET)

vb.net,string-parsing
I have a substring of text like so: Serial Port Name (COM 1) How would I go about getting the contents of the above parenthesis? Thank you in advance....

XmlReader DataGridView flip column and rows

xml,vb.net,datagridview
Using VB.NET I'm binding a DataGridView to an XML file using this code (for reading and writing) Global: Dim ds As New DataSet Dim sFile As String = "C:\test.xml" Reading: Using xmlFile As XmlReader = XmlReader.Create(sFile, New XmlReaderSettings()) ds.ReadXml(xmlFile) gridData.DataSource = ds.Tables("data") End Using Writing: ds.WriteXml(sFile) Here is what the...

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

asp.net,vb.net,gridview,datagridview
I have an application that allow me to import .xls/.xlsx file into a gridView. The .xls/.xlsx file is successfully imported into a gridView. There are a columns named Date, Name and Total in my gridView. How can I get the value from that dataGridView? I want to get all the...

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

vb.net,outlook,outlook-addin
So as the title says, I am trying to create a top-level folder in my Outlook but I haven't got any success with it. I've read several tutorials and code snippets but non of them seem to be a success. So now i Have this piece of code which creates...

vb.NET Screen Location

vb.net,location,screen
I'm working with a multi monitor setup. I know that you can do Screen.AllScreens(x) to get a specific screen, but is there any way to identify which screen is in which position? I.E. Screen 0 is on the right, screen 1 is on the left, screen 2 is in the...

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

c++,vb.net,visual-c++
I have a VB.net based interface like this: Namespace Foo Public Interface Bar ReadOnly Property Quuxes as Quux() End Interface End Namespace I now want to implement this in VC++/CLI (because I need to interface functions from an unmanaged third-party DLL), however I cannot figure out the correct syntax how...

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

database,vb.net,winforms,textbox
Here in my code, i have a database which has table of my applicants. As you will see in the code below, i want to get the number of rows from my command text and transfer it to the string "abc" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As...

Improve DataGridView rows managing

.net,vb.net,winforms,datagridview,datatable
SCENARIO I'm manually filling a DataGridView with a DataGridViewRow collection: I created the columns at design time in the GUI builder of Visual Studio. First column takes an Integer value, its a DataGridViewTextBoxColumn. Second column takes an Icon object, its a DataGridViewImageColumn. Third column takes a String value, its...

Multiple Alignments Inside Button

vb.net,button
Can you make a single string, within the same button, have different alignments? For example: dim String1 = "A B C D E F" A - would be in the top left corner B-in the middle top..... ...

String with Empty Variables

vb.net,string
Hey I am making a String but some of thevariables are going to be empty and I want these to be skipped but not sure how to go about this. Here is the code for the string below. Dim TenantList As String = Ten11 & "," & Ten10 & ","...

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

database,vb.net,ms-access
I am having a problem with my code where i am only able to add so many lines of text before i get an error "system resources exceeded". This is my code: Dim x As Integer = MsgBox("Update Record?", MsgBoxStyle.YesNo, "Are you sure?") If x = MsgBoxResult.Yes Then Dim accessconn...

Generic Interface missing implementation

vb.net,interface,implements,generic-interface
I have a generic interface, even if I state the type when I implement it, it says the implemented classes misses all implementation of members. The interface Interface IBuilder(Of T) Function Number(ByVal literal As String) As T End Interface The implement Class BracketsBuilder Implements IBuilder(Of String) Public Function Number(number__1 As...

xsd:complexType after xsd:attribute declarations yields error

xml,vb.net,visual-studio-2010,xsd,xml-validation
I have the following XSD: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="urn:com.xxxxx.xxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:com.xxxxx.xxx"> <xsd:element name="Stuff_EXT" type="DT_Analyse_EXT"/> <xsd:complexType name="Stuff_EXT"> <xsd:annotation> <xsd:documentation xml:lang="EN">Data Type Response</xsd:documentation> </xsd:annotation> <xsd:sequence> <xsd:element name="Res"> <xsd:complexType> <xsd:sequence>...

how can i use parameters to avoid sql attacks

sql,vb.net
I have a project without any parameters used in SQL queries. Is there any solution so that i don't have to change the function and validate parameters from the Query string itself? Query = "select * from tbl_Users where userName='"& textbox1.text &"' and password='"& textbox2.text &"' " ds = obj.ExecuteQueryReturnDS(Query)...

Why use And over AndAlso?

.net,vb.net
I'm fairly new to .NET programming, and I recently stumbled across AndAlso. As I understand it, AndAlso evaluates the first expression, if it is true then it evaluates the second...and so on. And, on the other hand, always evaluates all terms in the expression. If my understanding is correct, would...

Custom drawing using System.Windows.Forms.BorderStyle?

c#,.net,vb.net,winforms,custom-controls
I want to mimick drawing of default border based on value of property BorderStyle. Instead of single border around the control, my control is visualised as four adjacent custom-drawn boxes (2×2), each having standard border drawn individually. So for example, if Control.Border is set to FixedSingle value I want to...

Convert date to string format

vb.net,converter
I have successfully imported data from xls into dataGridView. The date column in dataGridView is showing the DateTime format. I want this date column to be displayed in "dd MMM yyyy" format. I have tried as shown below: connExcel.Open() Dim dtExcelSchema As DataTable dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing) Dim SheetName As...

How to text before a gridcolumn datafield

asp.net,vb.net
Hi I am getting a piece of data from my database that I am filling it into a grid. That part works fine. Now I want to add a URL before this data in DataField. The Data is called "RoutingNumber" I tried doing this with my code. <ComponentArt:GridColumn DataField='http://twilio.liquidus.net/handleincomingcall.ashx?call=<%# Eval("RoutingNumber")%>'...

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

xml,vb.net,linq-to-xml
Sample XML - <?xml version="1.0"?> <Root> <PhoneType dataType="string"> <Value>CELL</Value> </PhoneType> <PhonePrimaryYn dataType="string"> <Value>Y</Value> </PhonePrimaryYn> <PhoneNumber dataType="string"> <Value>555-555-5554</Value> </PhoneNumber> <PhonePrimaryYn dataType="string"> <Value>Y</Value> </PhonePrimaryYn> <PhoneType dataType="string"> <Value>HOME</Value> </PhoneType>...

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

vb.net,email
I'm trying to send an email via an outlook email account through a vb.net program. When I run the code I get an error telling me that I don't have a secure connection. I've been searching online and have tried all the adjustments I've found but I'm still not having...

Invoke form showdialog is not modal

vb.net,multithreading,invoke
I have 2 forms, 1 MainForm and 1 Form2. I am trying to display Form2 as a modal form and background from MainForm. Here's what I have so far. The default MainForm appears and after 5 seconds it will show Form2 as a Modal form from a background thread. I...

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

sql-server,vb.net,stored-procedures
I'm not sure what to believe anymore. When we are running our VB.NET SqlCommand off of stored procedures, do we add EXEC in our commands or not?! I get an error: Could not find stored procedure 'EXEC uspGrabAutoByYMM'. But then other people tell me you MUST put EXEC in there...

Syntax error in Insert query in Mysql in VB.Net

mysql,vb.net
I am doing project in VB.NET and backend is mysql Can you please tell me where the error is occured Public Sub ins() con.Open() 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...

Iterating through Twitch Json

json,vb.net,iteration,twitch
I'm not very good at this yet, not sure if my subject even accurately describes what I need. I know it's probably been answered, I'm having a hard time understanding the answers since they don't directly apply to my data. I am trying to figure out how I can iterate...

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

vb.net
I've seen plenty of questions here about strings that are equal returning as unequal, but trust me to not get that problem. I have this function. Protected Sub ChkValidStockCode() If Not (Voucher.ValidStockCode = "") Then Dim validcount As Int32 = 0 Dim validproduct As String = Product.GetProductNameByCode(Voucher.ValidStockCode) For Each rpi...

Can't output Guid Hashcode

sql,vb.net,guid,hashcode
I'm trying to use the hashcode of a guid as a random voucher name for a website, and have been trying to write new records to a SQL table with the Hashcode variable but it doesn't work. command.Parameters.Add("@voucherName", SqlDbType.NVarChar) command.Parameters("@voucherName").Value = Guid.NewGuid().GetHashCode() When using that code it just puts a...

ZipEntry() and converting persian filenames

vb.net,persian,sharpziplib
In my vb.net project I'm trying to add a file with a Persian name to a zip file and I do this with the code bellow: Dim myentry As New ZipEntry(dr.Item("MyFile").ToString()) zipOut.PutNextEntry(myentry) however when I open the zip file I see the file name is changed to a gibberish Is...

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

vb.net,inheritance
I have an existing project in VB.net with many Windows forms.I want to change all forms to deriven from a base form created in a class library. is there any way to do so? if i do inheritance with a code like this the designer dose not show the child...

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

vb.net,sendkeys,keyboard-wedge
We have an application (written in VB 2005) that reads incoming characters on a virtual serial port (on which a Cognex barcode scanner is connected), validate the stream and send it to the focused object using the SendKeyscommand. It has worked perfectly for years, but now customers have new software...

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

vb.net,linq
I have a list of objects and I have an array of keywords. I need to check if all the elements of the array are present inside the list of objects. The user enters the data to be searched like this pain+fever+thirst+itching My code looks like: //i check if the...

Using Linq with VB.NET

vb.net,linq
I am so sorry for asking such a thick question. I need to sort the characters in a string using vb.net. I normally use C#. This is my code: Dim val1() As Char = txtInput.Text.Trim.ToArray val1 = val1.OrderBy(c >= c).ToArray() Tells me that 'c' is not declared. I have imported...

Order LINQ query elements by a collection of numbers

.net,vb.net,linq,compare,compareto
This is a partially defined function that I'm using to retrieve the specified lines of a textfile, by passing the index of the lines I want: Public Shared Function GetLines(ByVal sourceFilepath As String, ByVal lineNumbers As IEnumerable(Of Integer)) As IEnumerable(Of String) Return File.ReadAllLines(sourceFilepath, encoding). Select(Function(line As String, index As Integer)...

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
I have created a table dynamically on an asp.net page by creating the rows based of off the number of rows in a dataset from a SQL database. I used a for loop to create my rows and cells with the populated dropdownlists in the page_load() function. My table is...

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

asp.net,vb.net,stored-procedures,hash,password-protection
I'm developing an ASP.NET application using SQL Server Stored Procedures. I need to hash my login password and resolve it in my sp_LoginCheck Stored Procedure. Any suggestions? I have already inserted data in the database. For example: UserName/Password ABC/123456 DEF/987654 I want to encrypt or hash whatsoever the password then...

Use String to find my.resources

vb.net
I have a number of resources called My.Resources.diceDark1 My.Resources.diceDark2 My.Resources.diceDark3... I want to do something like For i as integer = 1 to 10 button1.backgroundimage = My.Resources.diceDark i Next So it will cycle through all the resources and change the background image to that...

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

.net,vb.net,reflection,delegates,pinvoke
Is it possible to retrieve via Reflection the real method name that was passed through a lambda expression? I would like to platform invoke some functions with a better error-handling, then to avoid repeating tons of Marshal.GetLastWin32Error conditionals, I thinked in create a generic method to automate that, where I...

Append second datatable to existing datatable

sql,asp.net,vb.net
What I am trying to do is modify this code so I can fetch a second datatable to append, how do I append results of a second datatable? Dim myDataTable As New DataTable Dim sqlConnection1 As New SqlConnection("connectionstring") Dim cmd As New SqlCommand Dim reader As SqlDataReader Dim Family_id =...

Visual Basic Datagrid View change row colour

vb.net,datagridview,datagrid
Every other change to the datagrid view works fine but for some reason the row color just wont change. Ive debugged and my application goes through the loop to change the row color. Also I have a button that gives the datagrid view a new list and colors the rows...

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

vb.net
Suppose I have a project called FooProject with a file called FooModel.vb which contains the following interfaces: Namespace Foo.Model Public Interface Foo ' ... End Interface Public Interface Bar ' ... End Interface End Namespace When I output this to a class library and import the DLL, the namespace I...

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

vb.net,windows,visual-studio-2010,ms-access
I need to execute four queries and then if there is success must return true otherwise false. The queries affect the database but the function returns false Private Function save_to_data() Dim success As Boolean = False Dim conn As OleDbConnection = GetDbConnection() Dim total_due As Decimal = sanitize(txt_total_due.Text) Dim amount_paid...

Vb.NET Architecture with Option Strict On

vb.net,strict
I would begin to code with option strict on. I have a class Cell, that can be, numeric,data or string, included in a class table. How do can mask the type handling inside the classes? At first I thought at an Interface, but the classes that define the interface must...

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

vb.net,excel,visual-studio-2010
How can I output a file for each row of excel data? Right now it outputs the correct number of files but has the rows of data incremented, so file 1 is correct, file 2 has row 1 and row 2, etc. Dim smNum As Integer = 0 If rowct...

VB.net DomainUpDown Infinite Selection

vb.net
How can I get a DomainUpDown in vb.net to go from: DEFAULT then FLAT then LARGEBIOMES then AMPLIFIED then CUSTOMIZED then back to DEFAULT and so on? Like an infinite Selection.

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

vb.net,winforms,visual-studio-2012
I am trying to add a simple windows form to my VB.Net project. I have used the designer to design the form how I want it with buttons, a text box and a Timer. The problem is when I try to view the code, there is only an empty class...

.NET use IIF to assign value to different variables

.net,vb.net,conditional,variable-assignment,iif
Could I (and if so how) do the following in .NET language (more specifically VB.NET): Dim a,b as Integer if(somecondition=1,a,b) = 12345 Or any variant with IIF would be fine by me. Basically I'm always assign the same value but never to the same variable.....

Scraping Javascript webpage (script error occurred)

javascript,html,vb.net,web,scrape
I am scraping a dynamic webpage which is a javascript based webpage. I have done codes which is used to load the webpage first in the program: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load WebBrowser1.Navigate("http://www.changiairport.com/flight-info/flight-status/passenger-departures") End Sub However, each time I run the program, script...

Call controls inside view(xaml file) in viewmodel

wpf,vb.net,mvvm
I want to call controls inside view like button and item template inside viewmodel. Please tell how can I do that. My view contains following <ItemsControl Name="cDetails" Width="395" ItemTemplate="{DynamicResource Test}" ItemsSource="{Binding ViewModels}" Visibility="{Binding IsLoaded, Converter={StaticResource visibilityConverter}}"> <Button Name="btnComplete" Grid.Column="1" HorizontalAlignment="Center" Command="{Binding AuditCommand}" CommandParameter="1"> Complete </Button> Please tell how can I...

Where to store an mp4 file in my project?

.net,vb.net,visual-studio,mp4
I have been studying vb.net for a couple of months now and I want to try something new. I have this sample project to try. It is a web browser and I want that if a button will be clicked, a video will play immediately. This is what my application...

VBMath using / equivalent in C# [closed]

c#,vb.net
I want to use something like VBMath.Randomize(); and VBMath.Rnd(); In C#, I tried with using Microsoft.VisualBasic; But this doesn't work...

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

.net,vb.net
Consider a method that returns a Structure, like this: Public Function DoWork() As MyStructure Return New MyStructure(1.5, 1.7, 1.1, 55.9) End Function In this case, does .NET create and initialize a MyStructure value once, or twice? EDIT: My hunch is that a call to DoWork must involve .NET pushing the...

Simple explanation about loading files into memory

vb.net,visual-studio-2010,memory-management
What does it mean to "load into memory"? I watched some videos online where they were talking about reducing processing reports times, and they constantly say "you don't want to load a huge file into memory, instead read line by line." Can I have an example of what loading a...

How to remove text from textbox/label without flicker

c#,.net,vb.net
I want to create a textbox/label to display input/output from a serial connection. This program will be running over long periods of time, and since I don't want massive memory usage, I'm periodically reducing the length of the textbox content when it reaches a maximum value. Unfortunately, I've found that...

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

vb.net,visual-studio-2013,cmd
I would like to get the results from executing "query session" in the cmd.exe and Store them in a string variable using VB.NET. I have been searching for two days now and I cannot get to run the command, I will try to save the result once I get the...

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

asp.net,.net,vb.net,linq,datatable
Say you had a table in SQL and you wanted to find all the rows where a particular column could be one of 3 options. You could write something like this: SELECT * FROM MyTable WHERE uid IN (123, 456, 789) That's effectively what I want to do with a...

VB.Net DateTime conversion

jquery,vb.net,datetime
I have a jquery datepicker in a usercontrol. On the usercontrol i have a property that will return the selected date to the page which contains my usercontrol. I try to convert the string to a date: Dim MyDate As System.DateTime = System.Convert.ToDateTime(txtFromDateF.Value, System.Globalization.DateTimeFormatInfo.InvariantInfo) i keep getting the error: String...

Silverlight: Get first TextBox in DataTemplate

vb.net,silverlight,datatemplate,children
So far I have looked at several questions and answers for how to get a TextBox within a DataTemplate, but none of it is working for me. I have xaml like so (minimal example). The data template is in my section for static resources, and the ItemsControl is in the...

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

vb.net,listbox
I am writing a simple application to read the value a textbox and add to a listbox control . But i have to pass the listbox control to function . Any suggestion ? Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load test("E:\Satyajit.txt") End Sub Public Function...

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

vb.net,string
i have a string containing value like this i ={11212} {22121} {3113} {4122} {5121} ...... ...... How can i count the total no of value ?...

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

vb.net,average,sortedlist
I have a sortedlist like this; public MeasuredValues as SortedList(Of DateTime, Double) I throw in a bunch of values. For example; MeasuredValues.add(New DateTime(2010, 1, 1),33) MeasuredValues.add(New DateTime(2011, 1, 1),13) MeasuredValues.add(New DateTime(2012, 1, 1),233) MeasuredValues.add(New DateTime(2013, 1, 1),331) MeasuredValues.add(New DateTime(2014, 1, 1),732) MeasuredValues.add(New DateTime(2015, 1, 1),123) Now I want to get...

Convert Double from String

asp.net,vb.net,visual-studio-2012,converter
When converting string to floating, the converter creates wrong results. ?Global.System.Convert.ToDouble("635705821821928755").ToString("0") "635705821821929000" ?Global.System.Convert.ToSingle("635705821821928755").ToString("0") "635705800000000000" I am working with VB.Net Visual Studio 2012, Framework 4 on ASP.Net Webpage. Is there any solution for converting huge numbers from string into floating?...

Getting variable encryption results with VB.Net and DES

vb.net,encryption,des
I'm working on an semi-internal encryption process for somewhat sensitive information. Email addresses and the like. I'm working with a few other developers at some sister companies on the project, and the requirements are that everyone's encryption can talk to everyone else's. We use a global password, encrypt and decrypt...

If and only if in vb.net 4?

vb.net,if-statement,.net-4.0
IIF seems to be unavailable in .net 4, do we have a replacement? IIf(condition = 0, True, False) Would be a simple if statement a good replacement?...

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

vb.net,file,file-access
I know how to write to a file, however, I want to be able to write to a certain line. I have a large csv file which has many lines. I can only write to the last line (using the writeline) but I really want to write to line x...

VB LINQ - Take one random row from each group

vb.net,linq,random
I'm trying to get one random row from each group of rows. I'm trying to use LINQ, but I'm not sure if that's the right approach. I'd like a Dictionary of Key/Name pairs. My table is as such: AnswerGroup AnswerKey AnswerName --------------------------------------------- 1 1 Yes 1 2 No 2 1...

Retrieve full path of FTP file on drag & drop?

vb.net,ftp
I can read the filename using next code when dragging a file from an Ftp folder browsed on Windows explorer. But is there a way to retrieve the full Ftp path? Private Sub DataGridView1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop Dim filename As String = "" If e.Data.GetDataPresent("UniformResourceLocator") Then...

Comparing arrays with numbers in vb.net

arrays,vb.net
I need a way to compare two arrays in vb.net and save result in third array: Dim KonRes(3) As Integer Dim UserRes(3) As Integer Dim YelRed(3) As Integer KonRes(0) = 1 KonRes(1) = 2 KonRes(2) = 3 KonRes(3) = 4 UserRes(0) = 4 UserRes(1) = 3 UserRes(2) = 2 UserRes(3)...

Formatting a drive in Visual Basic?

vb.net,format,drive
I have a ListBox that is being populated only with removable drives. The user selects the drives to be formatted and then the program should format those drives. However, I get the message that the specified file cannot be found. Here is my code. Public Class Form1 Private Sub Form1_Load(sender...

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

xml,vb.net
So, I have a simple code to get the value of connection string from XML. connectionString = root.<TestDB>.Value.ToString As you can see, "TestDB" is the element name that gives me connection name. I want to replace this "TestDB" with a variable. Sadly, I am unable to figure out how to...

Delete file after “x” second after creation

vb.net,function
I want to delete file after 15 second of create that file. I use this code but no success. Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click Dim test = Application.StartupPath & "\" + tte4 Timer1.Enabled = True If Timer1.Interval = 0 Then My.Computer.FileSystem.DeleteFile(test) End If End Sub...

If value is not found while searching excel

vb.net
I have the below code: Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet1 As Excel.Worksheet Dim rng As Excel.Range Dim codeabc As String Dim i As Integer If StoreNumber.Text = String.Empty Then MsgBox("Please fill out 'Store Number'") Exit Sub End If xlApp = CreateObject("Excel.Application") xlBook = xlApp.Workbooks.Open("C:\Users\jefhill\Desktop\MyUPS.csv") xlSheet1...

Automapper AfterMap function initialising classes

.net,vb.net,automapper
Can anyone please explain how does the AfterMap function initalises the class objects passed in the lambda expression? When i run this bit of code as myself, it populates the dest object with my details. i can't figure out how is it doing that? but if someone can tell me...

c# to vb using Sync Framework strange error

c#,sql-server,vb.net,microsoft-sync-framework,localdb
I followed Microsoft's walkthrough for Sync Framework which is written in C#. And I wish to translate it to VB. I have simplified the code as much as possible. Both codes compile fine. They are running under 2 projects within the same solution. C# runs fine, but VB gives the...

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

database,vb.net,for-loop,indexing
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim TimeNow As DateTime TimeNow = DateTime.Now With ReservationTableDataGridView For i As Integer = 0 To (.Rows.Count - 1) ListView1.BackColor = Color.Black Dim ToBeTested As DateTime ToBeTested = (.Rows(i).Cells(1).Value) # Console.WriteLine(ToBeTested) If ToBeTested > TimeNow.AddMinutes(45) Then Me.ReservationTableTableAdapter.Delete((.Rows(i).Cells(4).Value), (.Rows(i).Cells(1).Value), (.Rows(i).Cells(2).Value), (.Rows(i).Cells(3).Value))...

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

sql-server,vb.net
I created a Database with vb.net on top of it. Users are entering records into the system and updating them. Is there a way to capture who entered or updated the database? Example: LastModifiedBy | CreatedBy Joe Bob | Sally Joe ...

Adding contents of a DataViewGrid to access - VB

vb.net,gridview,datagridview
I've got quite the frustrating issue! My VB code below is intended to transfer the records in a DataGridView to an Access database. Let's say, for example, the gridview has three records Name|House|Age John|L|1 Rick|B|12 Fred|A|20 The 'name|house|age' is the header of the GridView, whilst the three records make up...

Gridview items not populating correctly

asp.net,vb.net
I have data I am trying to input into a gridview. I am looking up the number of rows for the gridview and adding data into them like this: My "test" however does not get populated into the Submitted and Variance BoundFields in the Gridview. All that populates is the...

Explain what problems could have this function (if any)

.net,vb.net,winapi,pinvoke,getlasterror
SCENARIO When P/Invoking, I thinked it could be a great idea to simplify/reduct tons of code by designing a generic function that calls the function, then it checks for the GetLastWin32Error I'm using this code: ''' <summary> ''' Invokes the specified encapsulated function, trying to provide a higher safety level...

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

c#,.net,vb.net,visual-studio-2013
This question already has an answer here: Can I change my programs tray icon while it runs in c#? 1 answer I just want to know how to change the default program icon to have the current time on it and have it update whenever necessary. Thanks for any...

Get List of Elements in Tree with specific Field Value

vb.net,linq,properties,interface
I have an Interface like this: Public Interface TreeSelectorAttributes Property selectedInTreeSelector As Boolean Property Name As String ReadOnly Property childs As IEnumerable(Of TreeSelectorAttributes) End Interface and I have a TreeView which has a List of this TreeSelectorAttributes: Public Property rootList As IEnumerable(Of TreeSelectorAttributes) now after the User chooses which elements...

Return index of word in string

arrays,vb.net,vbscript
This code: Module Module1 Sub Main() ' Our input string. Dim animals As String = "cat, dog, bird" ' See if dog is contained in the string. If Not animals.IndexOf("dog") = -1 Then Console.WriteLine(animals.IndexOf("dog")) End If End Sub End Module Return start position 5 in string But how to return...

Getting value of Date Time Picker and using BETWEEN for filtering date in Ms Access database

vb.net,ms-access,oledb
I have a From and To DateTimePicker. I converted them into a String and use it to filter a MsAccess database of a specific range but there is a problem with the filtering. For example, I would like to filter from January 1, 2015 to January 31, 2015. The results...

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

vb.net,encryption,cryptography,aes
I'm aware of the other thread on this issue (AES decryption error " The input data is not a complete block." Error vb.net), but I'm either not implementing the solutions offered there correctly, or something about my particular variant of this issue isn't covered by those solutions. In any event...

Replacing string at certain index of Split

vb.net,string,visual-studio-2010
Using streamreader to read line by line of a text file. When I get to a certain line (i.e., 123|abc|99999||ded||789), I want to replace ONLY the first empty area with text. So far, I've been toying with If sLine.Split("|")(3) = "" Then 'This is where I'm stuck, I want to...

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

vb.net
I've been doing this, is it possible to get the middle string in datetime. Example : Basically my string return this '12/23/2015 12:00:00 AM'. However, what i want is actually '15' from the year 2015. I've been using something like this 'strDate = strDate.Substring(0, 9)', which sometimes return me wrong...

Connecting to database using Windows Athentication

sql-server,vb.net,authentication,connection-string
I would like to use window authentication in my program to connect to my sql server. users already have certain permissions on the SQL server and I would like to leverage that in my program. The way I currently connect to the server is using this connection string. Dim ConnectionString...

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

vb.net,winforms,visual-studio
If I use ShowIcon in the form properties, I get the icon in the top left of my form (I don't want that), but I do get my icon in the taskbar. If I turn ShowIcon off, then I get no icon on the form but I get the default...

NullReference Error while assiging values of Modeltype in MVC View (Razor)

vb.net,razor,model-view-controller,model
I have the following MVC Model: Public Class Employee Public Property EmployeeID As Integer End Class Controller: Namespace Controllers Public Class EmployeeController Inherits Controller Function Details() As ActionResult Dim employee As Employee employee = New Employee employee.EmployeeID = 101 Return View() End Function End Class End Namespace View: @ModelType MVCDemo.Employee...

Filter bind source

c#,regex,vb.net
I have a bind source which is filled with following data TOM JACK JACK TOM TOM DEISE JACK JENNY TOM DALTON JERRY JOY JOY JERRY And I have a combobox which is also filled with the above data, For example If i choose JACK TOM then the boind source should...

Manipulate visio shapes with data passed from vb.net

vb.net,visio
I have the below code which is opening visio, opening a file in visio, printing the file and then closing; this all works fine. However, now my task is to pass information over to the visio document page called 'Ticket Task', bind that information to some shapes and then print...

Using psql options in npgsql

vb.net,postgresql,postgis,psql,npgsql
I'm using npgsql in a small app used in the library I work for. Originally my app (vb.net) was using sendkeys.send and sendkeys.sendwait to type psql commands in cmd. This works but its slow and inefficient (ugly, buggy, etc.). I typically use the \o and \H options in psql to...

Removing Alert When Using DeleteFile API

vb.net,vba,api,delete
I'm writing a VBA application which involves looping a large number of directories recursively. I am using the FindFirstFile API to to achieve this, as it offers a substantial performance boost over the FileSystemObject. In order to remove the FSO from my code entirely, I need a routine to delete...

Want to create function validating textbox with letters only

vb.net,winforms,visual-studio-2010
And another function to validate specific format like " ad12-XYX- 123-EFD-20" I have created the function for numbers only' I want something similar to this Private Sub AllowNumericonly(Byval CTRL As control) if not Isnumeric(ctrl.text) And Ctrl.test<> "" Then MSGbox("Please enter numbers only." , Vbinformation) ctrl.text = "" ctrl.focus() End if...

Check if VB.net dataset table exists

vb.net,if-statement,dataset
I have the following code to check if my table exists before proceeding If ds.Tables(3).Rows.Count = 0 Then MsgBox("Nothing!!!!") Else DataGridView1.DataSource = ds.Tables(3) The trouble is I keep getting the error "Cannot find table 3." How in VB can I check if the table exists, rather than my application erroring...