Click here to Skip to main content
15,890,845 members
Everything / Programming Languages / Visual Basic 12

Visual Basic 12

VB12

Great Reads

by Mr. xieguigang 谢桂纲
How to build my own 3D graphics engine from ZERO step by step
by Mr. xieguigang 谢桂纲
The ShellScript is originally developed for the debugging of my "genome-in-code" virtual cell simulation engine, but now it becomes a script language for a .Net program.
by William Costa Rodrigues
This article explains an easy method to download and update your WinForms application
by a_pess
Image File Format

Latest Articles

by William Costa Rodrigues
This article explains an easy method to download and update your WinForms application
by Mr. xieguigang 谢桂纲
How to build my own 3D graphics engine from ZERO step by step
by Mahesh Rajaram Shinde
This project is designed for addressing SQL Server Script deployment on multiple servers and databases.
by David Vanson
Generate you own barcodes for your business, Promotional items or to share links with friends.

All Articles

Sort by Updated

Visual Basic 12 

22 Nov 2023 by Member 16146638
I am using SQL Server in a Vb.net program and when I try to specify an index with an ExecuteReader command that should be used, I get an error message about forceplan. I would like to use the index since it gives the best access. How do i force...
22 Nov 2023 by Richard MacCutchan
SET FORCEPLAN (Transact-SQL) - SQL Server | Microsoft Learn[^]
27 Oct 2023 by Member 15109325
Old school stuff, but I'm old. I've watched numerous videos and read various techniques of creating objects dynamically (control arrays), most of the techniques involve a Button_Click Sub that creates one object per click. I'm creating the...
25 Oct 2023 by OriginalGriff
They don't have "name variables" because they are created at run time (when your app is executing) rather than at compile time - so the only time anyone knows how many of them there are is long after all the variable names have been assigned. So...
4 Jul 2023 by Sravudh Daengmak
I Have 100 Textbox or more in form when I Fill Data finish in any textbox the data form textbox to show 1 label What I have tried: my Problem is I don't want to coding textchange event for each textbox I am sorry about my Grammar T_T
4 Jul 2023 by OriginalGriff
As the others have said, that many textboxes on a single form is a pretty poor UI design: it's difficult to manage, difficult to code for, and difficult for a user to process. It also probably looks very ugly! :D If you need to present or...
26 Mar 2023 by Graeme_Grant
If you want to pass the event from the UserControl to a parent container, like a Form, then you need to: 1. expose either a Method to a delegate (a method or function to call from within the UserControl) or 2. add a public Event property to the...
25 Mar 2023 by Mark Allan Wright
I have a RectangleShape, That I named Flng1, on a usercontrol and I need the MouseDown Event to work for the usercontrol to the form I place it on. It seems I can make the Click event work with this OnClick(EventArgs.Empty) but when I use this...
25 Mar 2023 by Mark Allan Wright
This is the code I have a RectangleShape on the Usercontrol called Flng1. This works when I use OnClick(EventArgs.Empty) but I need to have a Button2 action happen so the click won't work. Hope this helps. Private Sub Flng1_MouseUp(sender As...
25 Mar 2023 by Richard MacCutchan
An unhandled exception of type 'System.InvalidCastException' occurred in Ultra30007810.exe You have an error in your code, but since we cannot see the source we cannot help, beyond repeating what the error message states.
31 Jan 2023 by Member 2526425
I am trying to get an ODBC source on a computer to recognize the database the ODBC source points to. What I have tried: I've set up the ODBC source, I have the database installed and in place on the server and I have the put some things into...
26 Dec 2022 by Graeme_Grant
As OriginalGriff pointed out, it's much easier to use objects to represent The deck, cards, etc. If you think about it, it is no different from the actual objects in real life. A card has a suit and value. A deck has a number of cards. A dealer...
26 Dec 2022 by Jo_vb.net
For my cards game I have a lot of code like that: If sHandCards IsNot Nothing Then If sHandCards.ToString.Contains("7") Then Return "7" If sHandCards.ToString.Contains("8") Then Return "8" ...
26 Dec 2022 by OriginalGriff
Do yourself a favour, and don't use strings at all. Create a Card class, which has a Value and a Suit and then a Deck class which contains a List of Card objects. Populate the Deck with all 52 possible cards, and then write a Shuffle method that...
7 Dec 2022 by pham thao 2022
hi I'm new to coding, I'm have a Visual Basic project for the memory game. it basically lets the player flips over 2 cards, if those 2 cards match, they disappear, if they don't, they flip back. the game end when all the cards disappear. I have...
7 Dec 2022 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
2 Oct 2022 by Soft Management
Hello, I am Using Vb.net. I want to Use Sql Mdf Db as Attached Db (Without Sql Server). I Already Attached Mdf File For Single User but When I am Using in Another System via Lan Or Network Drive then Error Showing Process With Another....
2 Oct 2022 by Richard Deeming
LocalDB is, as the name suggests, a local database. Trying to share it between multiple users isn't going to end well. And the AttachDBFileName option is an extremely bad idea. SQL Server will create a separate user instance for each running...
30 Sep 2022 by OriginalGriff
You can ... just stick the DB file on a shared folder and let the remote connect to it. But ... it's a really bad idea. Yes, it can be done; yes, it can work. But every single time I've done it it's caused more problems than it's solved. Access...
21 Jun 2022 by Richard MacCutchan
Look at the code: Dim conn As New OleDb.OleDbConnection Dim dbProvider As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" Dim dbSource As String = "Data Source = C:\Users\Sam\Documents\User Accounts.mdb" Dim adapter As...
21 Jun 2022 by NyikoB
I created a login project in visual studio using VB.NET and MS Access as database. When I run the project for login it gives me the following error below: "Object reference not set to an instance of an object" What I have tried: Imports...
20 Jun 2022 by OriginalGriff
That's the least of your problems ... so little code, so many problems. Let's start with the one you have noticed, because it's one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most...
8 Jun 2022 by Member 15666915
Private Sub txt_a_qty_TextChanged(sender As Object, e As EventArgs) Handles txt_a_qty.TextChanged txt_a_qty.Text = Val(txt_b_qty.Text) - Val(txt_so_qty.Text) End Sub this is mean the available quantity equal the buyed quantity minus the sold...
8 Jun 2022 by OriginalGriff
Look at the Math.Min operator: mostYouCanHave = Math.Min(qtyInStock, qtyOrdered)
22 Apr 2022 by NyikoB
I developed an application for registration kids at Creche. There's one text box where I need a child's identification number. In this number it starts with a year e.g. 22 for 2022, and I need this number to increase automatically and in sequence...
22 Apr 2022 by gggustafson
Using a MariaDB with table named Last_ID, I use the following whenever I require a new unique id. BEGIN SET @last = 0; SELECT `last_member_id` FROM `Last_ID` WHERE id = 1 INTO @last FOR UPDATE; SET @last = @last + 1; UPDATE `Last_ID` SET...
4 Apr 2022 by razrx
What I want to achieved. IN MY DGV COL1 COL2 COL3 ITEM1 1 1 ITEM2 2 1 ITEM3 3 2 ITEM4 4 2 ITEM5 5 3 ITEM6 6 3 ITEM7 7 4 ITEM8 8 4 ITEM9 9 5 ITEM10 10 5 ITEM11 11 6 ITEM12 12 ...
4 Apr 2022 by OriginalGriff
A better way would be to use a loop: For i As Integer = 0 To 14 DGV.Rows(i).Cells(2).Value = i + 1 Next But ... since indexes are zero based, the column you want to index is probably 1, not 2
4 Apr 2022 by Richard MacCutchan
For row As Integer = 1 To 14 DGV.Rows(row).Cells(2).Value = row Next
27 Jan 2022 by cgthanes
Hi Friends,I m recently doing a program were import the data from Excel to .mdb access file using vb.net. But i have some problem, the data were inside the excel file is cannot import into the access file. can anyone help me? Please your help is required....Thanks.Best Regards,...
27 Jan 2022 by Member 15515171
This code is working for me also thanku sir But What if my sheet name changes many time or I don't know sheet name
17 Jan 2022 by lov kiemtheng
Hello, guy. I want your help to check this code below, I try to create a program which can help me to extract the URL in any website which has URL begin with "https://edge" and end of URL must to "playlist.m3u8". but the code i do is not working,...
17 Jan 2022 by CHill60
Your regex seems over-complicated and doesn't check for playlist.m3u8 at all. Why not keep it simple with ^https://edge.*playlist.m3u8$ - ^https://edge line must start with "https://edge" - .* followed by zero or more characters - playlist.m3u8$...
17 Jan 2022 by alip1
I have a report drawn through SSRB 3.0. The report is of the .rdl type so through VB.NET code and Report Viewer is hooked and displayed. The data set is managed dynamically so that records can be filtered according to the user's needs. The...
17 Jan 2022 by Richard Deeming
If you want to set the header via code, the simplest option is to add another parameter, pass the required title in that parameter, and set the text box's text to that parameter. Otherwise, you could use an expression for the text box parameter,...
6 Jan 2022 by Member 14169150
Greeting! How can I print items barcode sticker in datagrid view based on quantity I used this code but it reprints all items with the quantity of each item For i As Integer = 0 To DGVItem.Rows.Count - 1...
6 Jan 2022 by Member 3892343
Thank toy all I will try import/export first and then backup. Kyriakos
5 Jan 2022 by Member 3892343
I have a database that will be full of data, I want in vb net ro clone this database, rename the cloned database and delete the all data of the original database. I want to use smo to copy/clone the database not backup the database, also any...
18 Sep 2021 by Daan Assenberg
CmpCommand = New OleDbCommand("Select * FROM tblCompetitie WHERE((verID)=myVerID) ORDER BY comOmsch", BiljartConnection) CmpCommand.Parameters.Add(MyVerID) CmpAdapter = New OleDbDataAdapter CmpAdapter.SelectCommand = CmpCommand CmpTable = New...
18 Sep 2021 by Richard MacCutchan
CmpCommand.Parameters.Add(MyVe...
18 Sep 2021 by Richard MacCutchan
See OleDbCommand.Parameters Property (System.Data.OleDb) | Microsoft Docs[^] for the correct way to add property values to an OleDbCommand.
18 Sep 2021 by AdvenSQL
Plz Help I am using visual studio 2017, sql server 2016 I need to fill listview2(Containing Sub Departments) with checkboxes, based on another listview1 checked items & when I select an item in listview1 its all sub departments from Sql server...
18 Sep 2021 by Richard MacCutchan
Check the documentation: ListView.ItemCheck Event (System.Windows.Forms) | Microsoft Docs[^]
25 Aug 2021 by VBeginner.NET
You would know all of Fortran IV if you knew some 40 (just guessing) key words or "reserved" words like CONTINUE, DO, END, COMMON, EQUIVALENT, SIN, INTEGER, SUBROUTINE, etc. Does someone know this number more accurately? (Later, these words were...
25 Aug 2021 by OriginalGriff
Quote: Of course not, and I am not programming in Fortran these days. I am just trying to compare the number of key words. And Dave has given you the answer, or at least the means to get the answer. Go to the link, and start counting. Then...
25 Aug 2021 by Dave Kreskowiak
Keywords - Visual Basic | Microsoft Docs[^] FORTRAN 77 doesn't have any reserved words, but that doesn't mean using any keywords is a good idea.
19 Aug 2021 by VBeginner.NET
What is the best way to share a couple of forms and modules in two projects? The two projects are not quite like one solution, but have some things in common. I would like to produce separate .exe files for the two projects. Is it possible to...
19 Aug 2021 by OriginalGriff
The way I'd do it is to create three projects: the two EXEs and a DLL which contains the "common stuff". Create that as a Class Library and add a reference to the project in both EXE projects. Then all you have to do is add the appropriate...
19 Aug 2021 by Richard Deeming
You'll need to create a Windows Forms Control Library project and reference the compiled output from both projects.
16 Aug 2021 by VBeginner.NET
After the splash screen appears and fades away, the main form appears but goes behind some other program's windows like Windows Explorer or Firefox. What do I have to do so that it comes and stays in the front of all other windows? Thanks for any...
16 Aug 2021 by OriginalGriff
You'll have to use user32.dll: c# - How to make a window always stay on top in .Net? - Stack Overflow[^] See the clammum solution - it's not in VB, it's pretty obvious code.
16 Aug 2021 by Richard MacCutchan
You can use the Form.TopMost Property (System.Windows.Forms) | Microsoft Docs[^].
24 Jul 2021 by Member 3892343
I have made a vb net app connecting to an sql database, I used binding navigator datagridview and biding source, I instead want to use toolbox buttons, textboxes and not bindigsource. What I have tried: this code works Imports System Imports...
24 Jul 2021 by Member 3892343
Remember the solution code in vb .net Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.BindingContext.Item(DataSet11, "Table_1").AddNew() ' Me.DataSet11.Table_1.Last ...
24 Jun 2021 by Maciej Los
I'd strongly recommend to read this: Where Should I Store My Data?[^] The way to get user documents folder is to use: Environment.GetFolderPath Method (System) | Microsoft Docs[^]
24 Jun 2021 by Member 14063966
Hello, I have an application developed in VB.NET (windows forms) that internally generates files for later use. How can I define a specific directory to perform this action, without writing to the root directory of the application. I should...
11 Apr 2021 by Jo_vb.net
I need the correct text line / position from a text box. Using e.Location.Y of the mouse position works for all lines but not for the last line at the bottom of the text box. The text box has scrollbars. If the last line at the bottom of the...
8 Apr 2021 by Shadar4263
I used to be a programmer (VB, VB .Net, VBA, Access) and DBA (SQL Server) I haven't programmed in many years and now I am trying to convert some old code from an Excel VBA function to VB .NET and it is driving me batshit crazy. This is the line:...
8 Apr 2021 by Shadar4263
For those that are interested.... this is what I am working on. It is for moonphases, moonrise, moonset, etc. This is only part of it. It was originally written by Michael Friedrich for excel, and I am adapting it for .net. Option...
8 Apr 2021 by Maciej Los
I'm not sure what you want to achieve, but... You should use proper .NET data types and functions. See: Dim Thisdate As DateTime = New DateTime(2021, 7, 8) Dim JanuaryFirst As DateTime = New DateTime(Thisdate.Year, 1, 1) Dim tdiff As TimeSpan...
14 Jan 2021 by Member 11903597
hi guys , thanks for your time .i want to search between two dates in vb.net (in datagridview) , usingtwo datetimepicker .please help me !!
6 Oct 2020 by Q8Falcon
Hello Everybody i need a help with my VB.Net Code, I would like to be able to list all files that are currently open by process for example "EXCEL" so i can get the files paths. currently im using the following code which retrieve only the...
30 Jul 2020 by Member 14903326
i need to convert this code to visual basic for a proyect that i did not know that was to be in viasual basic form and to be honest i don't have much time so if anyone can help me that could be amaizing What I have tried: #Se muestran los...
30 Jul 2020 by ilmualam
Thank you so much for this kind of question. This is what I want to know, THANK YOU.
30 Jul 2020 by OriginalGriff
Step 1: Learn Python. Step 2: Learn VB Step 3: Use the Python code as a specification for a new VB app. Never convert languages, it doesn't produce good code in the target language because it uses a totally different framework, and the data...
20 Mar 2020 by OriginalGriff
An SqlConnection can only support one DataReader at a time: when you "share" a connection you have to make sure that the reader is closed and disposed when you are finished with it at all times. The best approach is not to "recycle" SQL...
20 Mar 2020 by codejet
Try enabling MutipleActiveResultSet in your connection string add this MultipleActiveResultSets=True
20 Mar 2020 by Xion1624
Private Sub tmchat_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmchat.Tick Using cmdreadchat As New MySqlCommand("SELECT chat FROM tb_chat", Conn) Dim chatreader As MySqlDataReader ...
20 Mar 2020 by ZurdoDev
You are closing the reader inside of the loop where you are reading from it. Move your close code to outside of the loop.
16 Mar 2020 by Xion1624
Private Sub tmchat_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmchat.Tick Dim cmdreadchat As New MySqlCommand("SELECT chat FROM tb_chat", Conn) Dim chatreader As MySqlDataReader chatreader =...
16 Mar 2020 by Dave Kreskowiak
It appears that you made the mistake of using a single SqlConnection object throughout your entire class. That's the wrong way to do it and leads to problems like this. ALWAYS create your connection when you need it, like in this method you...
16 Mar 2020 by OriginalGriff
An SqlConnection can only support one DataReader at a time: when you "share" a connection you have to make sure that the reader is closed and disposed when you are finished with it at all times. The best approach is not to "recycle" SQL...
14 Mar 2020 by Maciej Los
I'd suggest to start here: Google[^] When you get stuck, come back here and ask detailed question.
25 Jan 2020 by Patrice T
query = "Select * from login where Username= '" & txtuser.Text & "' AND Password = '" & txtpass.Text & "'" Not necessary a solution to your question, but another problem you have. Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens...
25 Jan 2020 by Marky Angel Kevin Garcia
hi im new here just want to seek some help on my project i need my log in form to accept only what the users registered credentials and yes they can login using there credentials but the thing is even if the password is on uppercase letters the user can access it by only using lowercase letter...
25 Jan 2020 by Richard MacCutchan
First point, do not use string concatenation to create SQL statements, it leaves your system vulnerable to SQL injection. Use parameterised queries always. Second point, do not store passwords in clear text, use salted hash values always. See Secure Password Authentication Explained Simply[^] ...
25 Jan 2020 by Wendelius
Don't do like this. Never ever concatenate values directly to an SQL statament. It leaves you open to SQL injection. Instead, use MySqlParameter Class[^] Another thing that never must be done, don't store the password as plain text in the database. To do this correctly, see Password Storage:...
7 Oct 2019 by OriginalGriff
Quote: taking into consideration that Excel.xls file has no Empty records Are you sure? Most Excel files have more empty records than non-empty: all that lovely whitespace at teh bottom! Since you don't specify any limits on what rows are returned: MyCommand = New...
7 Oct 2019 by BassamKassem
My problem is that when uploading bulk records to SQL Server database through VB.Net it creates a lot of EMPTY records after Inserting all records inside the xls file how to eliminate this issue. taking into consideration that Excel.xls file has no Empty records . What I have tried: ...
4 Oct 2019 by BassamKassem
Hi everyone I have an application that manages database . This application is used by 40 different computers over a shared network drive. What I have tried: I was using .mdb MS Access database and this file was on a network shared drive tp which my VB.net application connects. This was good...
4 Oct 2019 by RickZeeland
Here is a list of Access alternatives: 8 Microsoft Access online alternatives worth looking at -[^] Personally I'm a big fan of PostgreSQL, but that would of course mean a rewrite of your code, again :) https://www.slant.co/topics/3242/~best-lightweight-relational-databases[^]
4 Oct 2019 by OriginalGriff
Don't use Access as a multiuser DB - while you can do it, it's not a good idea and will always give you problems. For a 40 user network, I'd allocate a machine to SQL Server, and use that instead*. SQL Server is designed from multiuser working, and is much, much better at it - especially if your...
1 Oct 2019 by BassamKassem
I get an error call "Child list for field Customers cannot be created." after query execution specially after changing my sql queries to parameters instead of sql injection queries , here is the code //////UPDATES\\\\\\\ Sorry for not providing full info however here are the needed updates:...
30 Sep 2019 by Maciej Los
My best guess is... If you're adding condition to your query, you need to add parameters too: SQLText.Text = sqlQry Dim ds As DataSet = New DataSet Dim da As New SqlDataAdapter(sqlQRY, cnnOLEDB) Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da) ...
30 Sep 2019 by OriginalGriff
We can't help you based on that info: we have no idea what the base query you are appending to is, and that's probably relevant. I'd start by using the debugger: find out what exactly is in sqlQry when you create the SqlDataAdapter, and what exactly is in each parameter you pass over. At a...
26 Sep 2019 by William Costa Rodrigues
This article explains an easy method to download and update your WinForms application
23 Sep 2019 by OriginalGriff
Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead. When you concatenate strings, you cause problems because SQL receives commands like:...
22 Sep 2019 by BassamKassem
I'm getting this error after migrating my database from Access to SQL Server . below are that actions I need do but all of them gave me error "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM." 1- I need to search for all records that are exceeded 24 hours...
16 Sep 2019 by BassamKassem
When trying to use my VB.Net application to connect to accdb file that was originally converted from mdb using MS Access it the application gave me Unrecognized database format however when reversing the action and use the original mdb file it works normally also the migrated accdb file is...
16 Sep 2019 by Maciej Los
In addition to solution #1 by Richard MacCutchan[^] you'll need to change connection string. See: Access connection strings - ConnectionStrings.com[^]
16 Sep 2019 by Richard MacCutchan
You most likely need to upgrade to the latest Access DB engine: Download Microsoft Access Database Engine 2016 Redistributable from Official Microsoft Download Center[^].
11 Jun 2019 by shaileshshinde
when line is inserted after button click the cursor does not get pointed on the new line so,can i get some help for resolving my issue? What I have tried: RichTextBox1.Text = RichTextBox1.Text.Insert(RichTextBox1.SelectionStart, Environment.NewLine)
11 Jun 2019 by Richard MacCutchan
Same issue as your other question: https://www.codeproject.com/Questions/5099718/Save-error-in-richtextbox-in-VB-NET[^]. Please see the documentation for the RichTextBox.
11 Jun 2019 by shaileshshinde
suppose line typed in richtextbox is as below: hi my name is shailesh but when the file is saved.the saved files shows output as below: himynameisshailesh so,can i get some help for resolving my issue? What I have tried: SaveFileDialog1.Filter = "TXT Files (*.txt*)|*.txt|All...
11 Jun 2019 by Richard MacCutchan
See the Remarks section at RichTextBox.Text Property (System.Windows.Forms) | Microsoft Docs[^]
3 Jun 2019 by Richard MacCutchan
This is not a coding issue. You need to study the documentation for the switch that explains the web interface (if any) that will give you this information.
3 Jun 2019 by Member 10751808
Hi, I'm pretty new at this, so here goes... I'm trying to build a small vb program that will seek the information from the CISCO switch. Exemple: Switch name, Model, IP, Port VLAN Number and VOIP info. Just about the same as my FLUKE Link Runner AT1000. I would then use the prog at every...
2 Apr 2019 by Member 13305368
Hello, Can someone help me adding two text box without clicking a button. example: textbox1 = (1) textbox2 =(50) textboxsum = (51)
2 Apr 2019 by Leo Chapiro
I would implement the TextChange-Event on the both of the textbox1 and textbox2 like this: Try textboxsum.Text = Convert.toInt32(textbox1.Text) + Convert.toInt32(textbox2.Text) Catch ...
27 Feb 2019 by boudyonline
The reason was that file should be install SQLSysClrTypes after that it working well Thanks for all