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

Visual Basic

VB

Great Reads

by Fredrik Bornander
WPF Implementation of the spinning panel frequently used on the iPhone
by Steve Krile
Fully AJAX-enabled user control used to select names from a database in a drop-down format.
by Graeme_Grant
A Modern Toggle Switch - From mock concept to a full custom WPF control that you can plug into your own apps
by JosipK, Marko Kozlina
C# and VB.NET console applications that demonstrate how to create and send an email reply with IMAP and SMTP protocols in .NET Framework

Latest Articles

by Jo_vb.net
This article and the demo are about getting started using my Schafkopf_OOP VB.NET project.
by CODING_MLD
Expanding and collapsible panels implemented in VB.NET
by Allegra Angelo
Save, read and text recognition of network parameters
by Ralf Meier
This article revolutionizes Shelly device management, providing an updated, efficient, and feature-rich solution for both beginners and advanced users." You will discover new ShellyCom2 features, such as property manipulation using PropertyDescriptor, and a set of valuable helpers and commands.

All Articles

Sort by Updated

Visual Basic 

U 3 May 2024 by Thomas Lund 2022
Hi guys & girls I'm doing an application where I draw a system of machinery components in Visio, connect them and then import into the application to do a performance simulation and calculation of that system. Visio provide a convenient way of...
N 29 Apr 2024 by M-Badger
This is not tested (not in front of a machine with VS installed) but should work. It takes the approach of using the "image size in characters" and checking that against the result of GetCharIndexFromPosition. Private Sub...
U 29 Apr 2024 by 10071962
After having solved with the margin Get the left margin of a richtextbox[^] I have another question which also seems shrouded in mystery, in practically nothing exists on the internet, yet it seems trivial, like finding out when the mouse...
U 26 Apr 2024 by Richard MacCutchan
It is the view that gets sorted not the source table. So you need to capture the DataView object and display the row from there. See DataView.Sort Property (System.Data) | Microsoft Learn[^] for an example.
N 26 Apr 2024 by Andre Oosthuizen
You are accessing the row at index 4, which is the 5th row in the DataTable which is why you get the vale of '150. Datatable indexes start from 0 - Dim size1 As String = table.Rows(3).Item("Size") If you want to sort the DataTable by the...
U 26 Apr 2024 by Member 10974007
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim table As DataTable = New DataTable("Players") ' Add 2 columns. table.Columns.Add(New DataColumn("Size",...
N 24 Apr 2024 by Jens Madsen, Højby
Fixed: To get a pointer to the first char (or whatever), use 'Marshal.UnsafeAddrOfPinnedArrayElement(Buff, 0)' I believe that using GCHandle to pin 'Buff' isn't needed on a local variable, but you'd better check it!;)
N 19 Apr 2024 by Éric Côté 2021
I have created a Excel VBA macro that change the title bar of a VB.net application I have also created (Very simple Windows form application). The VBA uses Public Declare PtrSafe Function SendMessage Lib "user32"... The Applications works like...
17 Apr 2024 by 10071962
Since this topic is taboo, I post a possible solution, it works quite well, if ShowSelectionMargin = false returns 1, otherwise the value of the left selection margin which increases if we add SelectionIndent. I hope it helps anyone in my...
15 Apr 2024 by Andre Oosthuizen
You are using the EM_GETRECT message with the EM_GETMARGINS flag, which retrieves the formatting rectangle of the text in the rich text box, not the margins themselves - MS Learn | EM_GETMARGINS[^] To get the left margin of your richtextbox, you...
15 Apr 2024 by 10071962
It seems like an insurmountable secret, but there is little to nothing about how to get the left margin of a richtextbox, below what I tried: What I have tried: Private Function GetSelectionMarginWidth() As Integer Const EM_GETRECT...
15 Apr 2024 by Andre Oosthuizen
As Richard mentioned above, you have no code showing how you are going to loop through the mail items. You also need the 'Outlook.Items' and 'Outlook.MailItem' objetcs for it to work properly. Normally I will not show pointers with as little...
15 Apr 2024 by Member 15418280
I want to read email from outlook in excel macro i want to add some filter for fetching email like subject from date etc. What I have tried: I tried condition but not working below is the code. Public Sub CheckEmail_BlueRecruit() '...
1 Apr 2024 by Member 15485980
I have a VB windows form app with a datagridview. I changed one of the column types to a combobox, which works ok. However, when I close out of the form I get multiple 'datagridview default error dialogue' complaining about system.index out of...
1 Apr 2024 by lewist57
Well they say those that don't remember history are condemned to repeat it, and I guess that is true here. The following article does exactly what I was trying to do (with the exception of creating a .dll) from over 20 years ago: ...
27 Mar 2024 by joseph mahihu
Error BC30311 : says that, value of type string can't be converted to 'RichTextBox' Here is the link to the image of my code since you cant post pictures here What I have tried: I have tried introducing parameters but that keeps worsening the...
27 Mar 2024 by Pete O'Hanlon
If you are trying to add structured text into RichTextBox, you are going to be using the Rtf property which accepts a string that has text formatting in it. As you haven't actually shown any code, we can't offer much more support other than...
24 Mar 2024 by Graeme_Grant
I fired up VS and used your code in a console app. I modified it slightly with optimisations: Imports System.IO Module Program Sub Main() Dim directories As IEnumerable(Of String) = GetDirectories("c:\") If directories...
24 Mar 2024 by Dave Kreskowiak
It doesn't work because the EnumerateDirectories function will stop at the first sign of trouble AND NOT RESUME. It's not designed to enumerate entire drives of directories. To fix your code, you're going to have to write your own...
24 Mar 2024 by lewist57
OK, short (?) story: Trying to read the folders and subfolders for a given drive using vb.net and VS2022. Many online posts recommend use of Directory.GetDirectories (some going back 20+ years), but it generates errors when a directory is not...
19 Mar 2024 by Pete O'Hanlon
Without trying it, I would say the following would work. Choose the sqlite database in your Solution window and select Propeties. Set the type to Content and Copy To Content Folder Always. That should copy the database over.
19 Mar 2024 by Woody 2024
I have got a vb project which i would like to publish however when i publish it the sqlite database which i use doesn't seem to go with it. So, i cannot use the program when i distribute it to another computer. How can i make it so when i publish...
19 Mar 2024 by Graeme_Grant
I am not sure what you are trying to do however I'll show you how to handle each item in the ObservableCollection. The Item class needs to implement the INotifyPropertyChanged Interface (System.ComponentModel)[^]. Microsoft provide a sample: How...
17 Mar 2024 by Sh.H.
Hi guys Here we have listORG with 3 fields: Idx   ,   Etude   ,   Name ---------------------------------- 1         Etude1      John 2         Etude2      John 3         Etude3      John 4         Etude4      John 5         Etude5      Merry...
17 Mar 2024 by Pete O'Hanlon
You cannot tell if an object has been changed using an ObservableCollection. The way to do this is to use INotifyPropertyChanged and raise the PropertyChanged event whenever you change the value in a property.
17 Mar 2024 by Sh.H.
Hi folks. I have an Observation Collection. I used event CollectionChanged. But this event only raises when new item added, or an item deleted. So how can I detect if an item edited? (And ofcourse, it would better also to detect which item got...
17 Mar 2024 by Graeme_Grant
You would use a CollectionViewSource and use grouping. I assume that you are using WPF. Here is a sample: How to: Sort and Group Data Using a View in XAML - WPF .NET Framework | Microsoft Learn[^]. Hereare some more things that you can do with...
16 Mar 2024 by Gerry Schmitz
You don't need an ObservableCollection to "count"; but you can substitute if you want. public class Org { public int Idx; public string Etude; public string Name; } static List _listOrg = new...
12 Mar 2024 by carlitosd19
OK, I find a way to fix this: 1-Set you connection string inside the Data Source in the General Tab (include your username and password) 2-On the Credentials Tab, set "Do not use credentials" 3-Save the report and reopen and run it. that's all :)
12 Mar 2024 by OriginalGriff
There are problems here with what you want to do: you can't use a single ObservableCollection for two different lists, and while you could put all the items from both into a weakly typed ObservableCollection and cast them appropriately when you...
9 Mar 2024 by Andre Oosthuizen
Another solution will be to use the 'DispatcherTimer' control to sync your titles - C# DispatcherTimer properties[^] Your code will look like the following, adjust the 'SubtitleRecord' class and initialization parts based on your actual data in...
8 Mar 2024 by OriginalGriff
That's complicated, because the user can pause, fast forward, or rewind at any time, and you need to keep the subtitles in sync with the video or it will just get very confusing. Probably your best bet is to use the industry standard .SRT file -...
8 Mar 2024 by Sh.H.
Hi guys Here is a list with 3 fields: StartTime , EndTime , SubtitleText There is almost 1000 numbers in the list. So I have a VideoElement which plays the video, and I made a TextBlock on it to show this list as its subtitle. Could you please...
6 Mar 2024 by OriginalGriff
A column in a DB holds only one value: to hold muyltip[le values you would have to do one of two things: 1) Convert your "Checked" items to a comma delimited string, and your "Unchecked" items to another. Then store the strings in a single column...
6 Mar 2024 by Kamel Brahouni
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try 'CheckedListBox1.Show() DateTimePicker1.Value = Date.Now 'Dim cmd As New...
6 Mar 2024 by Andre Oosthuizen
The error is quite obvious, as you stated yourself, the report writer is trying to connect to your database, you gave it no login details and it will thus ask you for the detail. You need to specify the login details before you call the report so...
5 Mar 2024 by Member 8651586
while verifydatabase from vb.net web application for the cristal report gives Log on failed.error. here is my code. I am using project data (class defined in my visual studio project) as Database Fields do it should not need any logon I belive. ...
29 Feb 2024 by OriginalGriff
We can't tell - we have no access to your code, especially not while it is running. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how...
24 Feb 2024 by OriginalGriff
To add to what Dave has - rightly - said ... It is indeed quite possible there is no documentation: if that is true, or the necessary documents aren't easy to find then the best course of action is to dump it and look again. Quote: I have...
24 Feb 2024 by Dave Kreskowiak
There is no repository for documentation of all Nuget packages. Hell, there's isn't even a requirement for anyone making a publicly available Nuget package to include documentation or supply a link to any. It's entirely possible there isn't any...
24 Feb 2024 by Eli Schneider 2024
I am struggling with the implementation of a spell checker for my project. I have determined that the spellnet Nuget package is the best way to go. Using Visual Studio vb.net. I have found one example, but I am wondering if there is some better...
20 Feb 2024 by tMichu
Hi, the focus method doesn't seem to work on page change. I am using tabcontrol. What I have tried: I have tried to do textbox.focus() in methods Selecting, and SelectedIndexChanged, in both I have the focus() as last called method but it...
17 Feb 2024 by Knight school
Hi, I have storyboard with multiple double animations (Not all show in code to make it easier on the eye). I'm setting the duration in the double animation & have read you should also set the storyboard duration to same value to not cut short...
17 Feb 2024 by Jo_vb.net
I think this article could be a good starting point for you: Monitoring a Printer Queue from VB.NET[^]
17 Feb 2024 by Member 10218145
I have a VB.NET desktop application for a computer lab. I want that application to be able to detect a printing process thru a network printer & get how many pages my user are trying to print. What I have tried: I have not found any suitable...
16 Feb 2024 by Jo_vb.net
This article and the demo are about getting started using my Schafkopf_OOP VB.NET project.
16 Feb 2024 by Andre Oosthuizen
In addition to what OriginalGriff suggested, you can automate this rather than changing your code all of the time to ensure a successful connection - You need to dynamically adjust your connection settings based on the specific database version...
15 Feb 2024 by OriginalGriff
SQL databases are tagged with a version number: the version that wrote the database file. When your code connects to the DB via the SQL Server engine, it checks the engine version against the file version - if the DB shows a later version than...
15 Feb 2024 by yossef2023
Hello everyone, why does this message appear? microsoft visual studio an incompatible sql server version was detected. What I have tried: SSDT installed did not solve the problem Thank you all
15 Feb 2024 by CODING_MLD
Expanding and collapsible panels implemented in VB.NET
14 Feb 2024 by M Imran Ansari
Check the refer article and try to use "(localdb)\mssqllocaldb" as the server name for connecting to the LocalDB instance, for example: SQLCoffee - Breaking Changes to LocalDB[^]
14 Feb 2024 by OriginalGriff
Quote: Online. Is there a link to how to solve the problem? Read the message carefully: it says that it either can't find SQL server at the address given in your connection string, or the server is hosted on a different computer which is not...
14 Feb 2024 by yossef2023
Hello, what is the reason for this message? a network-related or instance-specific error occurred while establishing a connection to sql server. the server was not found or was not accessible. verify that the instance name is correct and that...
11 Feb 2024 by Ralf Meier
When seeing your Solution I want to suggest you some little modifications : Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click Cursor.Position = GetCenterOfControl(Button6) End Sub ...
11 Feb 2024 by M-Badger
I may be mistaken but I suspect that the difference is that vb 2015 programs will be consistent with the Windows 10 styling, including the larger title bar. Whereas vb 2010 programs will be accessing older libraries and their styling is therefore...
10 Feb 2024 by 10071962
Good morning, following the advice of my last post, "https://www.codeproject.com/Questions/5376961/Translating-yield-return-to-VB" I updated the 2010 version to the 2015 version. Now I have all the forms, and there are hundreds of them, with an...
9 Feb 2024 by Member 16123720
Thanks to OriginalGriff and Ralf Meier... Their guidance led me to the solution pasted below. But first, I need to clarify my originally posted scenario. It seems that the code line below WILL work if there is no other form opened during the...
8 Feb 2024 by OriginalGriff
The Location of a control is always relative to its container: if you have a GroupBox on a Form, and the GroupBox contains a Button, then myGroupBox.Location is relative to the top left corner of myForm.ClientRectangle, and myButton.Location is...
8 Feb 2024 by Member 16123720
Using VB 2008 Express. I have a Main form that has a number of Group Boxes. As desired, I can successfully position a Wait Cursor on a control on the Main Form that is NOT within a group box using the following code lines: (assume Button1 is NOT...
3 Feb 2024 by Jo_vb.net
Instead of a Loading Popup I would try a separate task or multithreading for loading the list. Multithreading with VB.NET - A beginner's choice[^] Tasks/Continuations and Death of the ThreadPool?[^]
3 Feb 2024 by tMichu
Hi, i am using tabstrip control, on one of the pages I have a combobox with list of pdf files from a network source and a webcontrol to show them. It is not sure if a user will change to this tab and that is why I am loading the list of files...
3 Feb 2024 by Knight school
Hi, I want replicate the drag & drop from file explorer but from my application which will be lislview item. i.e. Drag listview item (File path) to other application the same as explorer would work. There seems to be a lot of example dragging...
3 Feb 2024 by tMichu
Hi thank you for all the replies - like you said it's probably the driver issue. I changed the OriginAtMargins to True and moved the objects in the report so it's easier to control the result.
2 Feb 2024 by OriginalGriff
When you drag'n'drop from explorer into an app, the receiver neds to do a couple of things: 1) Handle the DragEnter Event Set the e.Effect to DragDropEffect.Copy, or DragDropEffects.Move 2) Handle the DragDrop Event and fetch the list of files by...
2 Feb 2024 by Member 12859920
Imports System.Runtime.InteropServices Private Shared Function SendInput( ByVal nInputs As UInteger, ByVal pInputs As INPUT(), ByVal cbSize As Integer ) As UInteger End Function ...
2 Feb 2024 by OriginalGriff
Erm ... you did read what SendInput does, right? It feeds keyboard and mouse info into the appropriate queues - which means that are extracted by the active application. Which since you just pressed a mouse button isn't Chrome: it's your app. ...
30 Jan 2024 by Lawyer Sonia
The issue may stem from the physical printer's settings or drivers. Ensure the printer driver is up-to-date and supports the A5 paper size. Additionally, check the printer's margin settings to prevent cropping issues, as observed with the Virtual...
29 Jan 2024 by OriginalGriff
Without your code, we can't be sure - but I'd guess it's something to do with margins. Because of the way they handle paper, some printers can't physically print on the left or right edges, or near the top or bottom of the page. These borders may...
29 Jan 2024 by tMichu
Hi, I have prepared a document on A5 page with e.Graphics methods. When I get the print preview window the layout of page is ok. When I send it to physical printer then it is cropped left upper corner is ok but bottom right is cropped. When I...
29 Jan 2024 by OriginalGriff
No, because we have no idea what POS devices you are using, how they connect to the page (or client) or how your code works. I'd start with the POS manufacturers website, they are likely to have sample code and tech support available and will...
29 Jan 2024 by yossef2023
Hello everyone, I have a page for selling meals on my website in the vb.net language. I need a code to link from the sales page to point-of-sale devices, and I do not know the code. Is the linking code available? Thank you. What I have tried: ...
26 Jan 2024 by OriginalGriff
To add to what the others have said, This is not a code conversion service: we are not here to translate code for you. Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different...
26 Jan 2024 by M Imran Ansari
No one else can undertake this task on your behalf since nobody has complete logic or understanding of your application; you must handle it independently with some code converter tools if you dont have understanding of JavaScript, better to learn...
26 Jan 2024 by lov kiemtheng
Hi all, I have no experience with javascript before, but I would like to convert the javascript below to vb.net, I really hope someone who expert on it will help me. What I have tried: window.onload = function () { // get m3u8 urls...
26 Jan 2024 by Graeme_Grant
As others have pointed out, you can't open MS Word on your website. However, you do have some options: 1. You can embed Word Documents for viewing. Here is a Google search with many examples of how: embed ms word on your website - Google...
25 Jan 2024 by Member 14809574
DataGridViewCellStyle headerStyle = new DataGridViewCellStyle { BackColor = Color.LightBlue, // Other style properties can be set here }; foreach (DataGridViewColumn column in dataGridView1.Columns) { ...
25 Jan 2024 by Dave Kreskowiak
Ummm... You CAN'T open Word on the page. The code you've written will open word on the web server, where nobody will see it, NOT on the client machine. The reason the code is failing is because you don't have Office installed on your dev machine.
25 Jan 2024 by Richard MacCutchan
The message is clear, the compiler cannot find a reference to the class or namespace Word in your source. Have you added a reference to Microsoft.Office.Interop.Word Namespace | Microsoft Learn[^], and included it?
25 Jan 2024 by yossef2023
Hello everyone, I want to know the reason for this error. I tried to fix it and failed. I want to open Word on the page. Thank you everyone. Is there a solution to this error? What I have tried: Server Error in '/' Application. Compilation...
24 Jan 2024 by Allegra Angelo
Save, read and text recognition of network parameters
24 Jan 2024 by BASSIES
I want to combine this code: If the USB present or not with certain number, and is the programm running from that USB drive. With this I get the USB numbers, and check if it is present: Dim USBClass As New...
23 Jan 2024 by James iLogic
Hi, I'm using Inventor iLogic to place a GeneralNote on a drawing if certain boxes aren't all filled out. There is a rule to identify this and it works and is set up in another rule, which activates this rule if there is a problem. These rules...
19 Jan 2024 by Member 10495533
this worked for me to change topleftcell: DataGridViewCellStyle columnHeaderStyle = new DataGridViewCellStyle(); columnHeaderStyle.Font = new Font("Verdana", 10, System.Drawing.FontStyle.Bold);...
18 Jan 2024 by Jens Eckervogt
If I suggest you to fix like char* from string. But I have already 2 different sbyte* and byte* formats from string. And I will release soon char* for Windows Users of WinAPI. Check out my article! If you use VB than you can use...
17 Jan 2024 by Knight school
Hi, This is difficult one to explain but here goes. I have a list of numbers which are to be set over a set number of column (Pre-determined by another calulation). The task it to move the number around till the shortest column height (Numbers...
16 Jan 2024 by Ralf Meier
This article revolutionizes Shelly device management, providing an updated, efficient, and feature-rich solution for both beginners and advanced users." You will discover new ShellyCom2 features, such as property manipulation using PropertyDescriptor, and a set of valuable helpers and commands.
16 Jan 2024 by Graeme_Grant
Quote: I tried converting with "https://converter.telerik.com/" and others but without success, System.NotSupportedException: UnsafeKeyword is not supported! Most of these are not well maintained or simply abandoned. What I find, as a better...
16 Jan 2024 by Maciej Los
I'd suggest to read this excellent article: How to do pointers in Visual Basic[^] These can be helpful too: Pointers in Visual Basic using Undocumented Functions[^] Pointers and Unmanaged Memory Handling in VB.NET | BinaryIntellect Knowledge Base[^]
16 Jan 2024 by Lawyer Sonia
To retrieve the distance value from a Google Maps direction link in VB.NET in 5 lines, you can use the following code: Dim directionLink As String = "YOUR_GOOGLE_MAPS_DIRECTION_LINK_HERE" Dim webClient As New System.Net.WebClient() Dim...
15 Jan 2024 by softotal
Thank you i found the solution I was using the event DoubleCLick but in stead i have to use the event CellMouseDoubleClick Thank you so much, much appreciated
15 Jan 2024 by softotal
I have a Datagrid that gets rows from a database table. I wrote code to populate a textbox when double clicking a row. If I doubleclick a row all is ok and no errors but if i doubleclick the area below the last row it gives me an error. This is...
15 Jan 2024 by Graeme_Grant
Further to Jo's answer, yes, the article link he has pointed you to does not give you the exact answer that you want however it does show you how to animate. The same principle applies. You need to take that and write the code or use the answer...
15 Jan 2024 by 10071962
Hello everyone, I'm translating a library from C# to vb.net, it's a complex job due to the many differences but it's almost done. The only point where I can't is the following: var CurrentWord = new StringBuilder(); char[] Buff =...
14 Jan 2024 by OriginalGriff
First off, stop using On Error - use the more modern Try ... Catch instead. Then look at the definition of the function: IDirect3D9::CreateDevice (d3d9.h) - Win32 apps | Microsoft Learn[^] Or the MS tutorial: IDirect3D9::CreateDevice (d3d9.h)...
14 Jan 2024 by Member 16182457
I'm having a issue on a project;I'm wanting to create a 3D image using directX 8 but I can't create the image because it throws out a exception : argumentnullException the argument of D3D.createDevice 's last parameter was null....
14 Jan 2024 by Jo_vb.net
I searched CodeProject articles... Animation using Storyboards in WPF[^] This may help you to write the code for your own needs.
14 Jan 2024 by Sh.H.
Hi people. Follow my previous post in How do I add new row in datagrid in WPF?[^] I need to know how may I use animation when a row adds or inserts into this DataGrid? I mean when I add or insert new row, it opens like curtain... or accordion....
14 Jan 2024 by Sh.H.
Hi. I found a solution. Below code works perfect. However, I think there is better way for this scenario. For example I think there could be a way to use CallBack and Filtering. But I do not have any idea. So please kindly help me to make a...
14 Jan 2024 by OriginalGriff
This is not a good question - we cannot work out from that little what you are trying to do. Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for...
12 Jan 2024 by Andre Oosthuizen
There is not much information to go on, I will however implement something like my code below. This is in no way a full solution, only a pointer for you in the right direction, you need to modify the code to work for you - Imports...