Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

Visual Basic.NET

93K

Solutions

24K

Contributors

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to  Visual Basic pre-2002, it is not the same technology,

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a .Net web page that has a datepicker that gives date in mm/dd/yyyy
On SeletedDateChanged I calculate the age in years with the code below...

I suspect this has holes in the logic as it is just getting the years without accounting for the actual date



            Dim curDate As DateTime = DateTime.Now
            Dim curyear As Int32 = curDate.Year
            Dim birthdate As DateTime = txtBirthDate.SelectedDate
            Dim birthYear As Int32 = birthdate.Year
            Dim yrsAge As Int32 = curyear - birthYear
            txtAge.Text = CStr(yrsAge)

Open in new window

0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi,
How Do I find the string has an apostrophe, single quote in the string.
I have a function
 Public Function ReplaceSingleQuote(ByRef val As String)
        '//***This function replaces the single quote to double quote***\\
        If IsNothing(val) = False OrElse val <> String.Empty Then
            val = val.Replace("'", "''")
            val = val.TrimStart
        End If
        Return val
    End Function

Open in new window

But, the problem here is that if use for multiple times for the same string it inserts too many single quotes.
Is there any way it just detects an single apostrophe and then replaces it with '' for sql compatibility.
Thanks
0
I have a vb.net App attached to a SQL MDF database.  Inno Script supports .net 45  The database is version 852.(2016+) MsSQLLocalDB will only run version 782database.   since inno script doesn't check for or install dotnet46, or the local db version, how do either:
ADD the new files to connect to this database or
Is there an existing script for the new version of dotnet.

OR should i consider a different installer.  This is not an area of my expertise and this will be installed on many different machines as a local APP.   I could use some advise.  Thanks
0
Hello,
I am getting an interop error
Could not load file or assembly 'Microsoft.Office.Interop.PowerPoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce19429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Office.Interop.PowerPoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9

Any suggestions?

Regards
0
I am having issues in VB bulk inserting text file to MDB. This is code that works at many client sites. I have resorted to testing my command in Access to make sure it is fit.

below DOES NOT WORK. the data is inserted, but only one column is created and all data goes into one column with the commas.
SELECT * INTO Record1TEST
FROM [Text;HDR=Yes;FMT=Delimited;Database=L:\22\vbapps.2015\SnapshotOP\SSImportOP\bin\x86\Release\].recordtype1.txt;

If I move the input file to D drive, below works:
SELECT * INTO Record1short
FROM [Text;HDR=Yes;FMT=Delimited;Database=D:\].recordtype1.txt;
0
Hello,
i have code :

    If NumberOFPictures <= 47 Then
                            Slidenumber = 2
                        ElseIf NumberOFPictures > 47 And NumberOFPictures <= 94 Then
                            Slidenumber = 3
                        ElseIf NumberOFPictures > 94 And NumberOFPictures <= 141 Then
                            Slidenumber = 4
                        ElseIf NumberOFPictures > 141 And NumberOFPictures <= 188 Then
                            Slidenumber = 5
                        ElseIf NumberOFPictures > 188 And NumberOFPictures <= 235 Then
                            Slidenumber = 6

                        End If

Open in new window

Is there any better way of writing this as the NumberOFPictures can be  even 2000

Cheers
0
Hello,
How can i add pictures placeholders on a powerpoint slide to appear next to each other and take a new  row when the row is full.
Also when the slide is full how it can autogenerate a new slide with placeholder for the pictures.
Currently I have a code for this, but its not very efficient as I am declaring the place of the placeholder.

Private Sub AddSlides()
        Dim intCurrSlide As Integer = ppPrsn.Slides.Count
        Dim currSlide As PowerPoint.Slide = ppPrsn.Slides(intCurrSlide)
        Dim objShape As PowerPoint.Shape = Nothing
        Dim pptLayout As Microsoft.Office.Interop.PowerPoint.CustomLayout
        pptLayout = ppPrsn.Slides(1).CustomLayout
        Dim length = l + 7
        Dim top = t + 10
        For i = 0 To 47

            pptLayout.Shapes.AddPlaceholder(PowerPoint.PpPlaceholderType.ppPlaceholderPicture, length, top, 75, 101)
            length = length + 78
            If i = 11 Then
                length = 10
                top = top + 130
            ElseIf i = 23 Then
                length = 10
                top = top + 130
            ElseIf i = 35 Then
                length = 10
                top = top + 130

            End If

        Next
        If ppPrsn.Slides.Count = 2 Then
            Dim slide As PowerPoint.Slide
            slide = ppPrsn.Slides.AddSlide(ppPrsn.Slides.Count, pptLayout)
        End If

        FlgSlideCreated = True

    End Sub

Open in new window

0
Hello,
I have a template to export pictures on a powerpoint template. The vb.net code adds slides to the template depending on the number of pictures to be exported. How can i delete the blank slides.
This the code I am using
 Private Sub AddSlides()
        Dim intCurrSlide As Integer = ppPrsn.Slides.Count
        Dim currSlide As PowerPoint.Slide = ppPrsn.Slides(intCurrSlide)
        Dim objShape As PowerPoint.Shape = Nothing
        Dim pptLayout As Microsoft.Office.Interop.PowerPoint.CustomLayout
        pptLayout = ppPrsn.Slides(1).CustomLayout
        Dim length = l + 7
        Dim top = t + 10
        For i = 0 To 47

            pptLayout.Shapes.AddPlaceholder(PowerPoint.PpPlaceholderType.ppPlaceholderPicture, length, top, 75, 101)
            length = length + 78
            If i = 11 Then
                length = 10
                top = top + 130
            ElseIf i = 23 Then
                length = 10
                top = top + 130
            ElseIf i = 35 Then
                length = 10
                top = top + 130

            End If

        Next
        If ppPrsn.Slides.Count = 2 Then
            Dim slide As PowerPoint.Slide
            slide = ppPrsn.Slides.AddSlide(ppPrsn.Slides.Count, pptLayout)
        End If

        FlgSlideCreated = True

    End Sub

Open in new window


This code clears the placeholders :

  Private Sub ClearPictureBoxes(ByVal parent As PowerPoint.Presentation)
        Try
            If IsNothing(parent) = True Then
 

Open in new window

0
Hi

I am looking for a Microsoft Cloud accounting system for a small operation.
I need to be able to send data to the accounting system from an ASP.net web app.
Is this possible with Microsoft Dynamics?
If not is there a better option?
Thanks
0
Hello ,
Need help in this query, please see the excel sheet for the expected result.

;WITH Drivers
AS ( SELECT   J.DriverID ,
              MAX(J.CollectionDatetime) AS LastAllocStDate
     FROM     Table_JOB J
     GROUP BY J.DriverID ) ,
     A
AS ( SELECT j.ID ,
            j.ClientName ,
            j.DriverID ,
            CAST(j.CollectionDateTime AS DATE) AS AllocStDate ,
            j.Allocation ,
            CAST(j.AllocEndDate AS DATE) AS AllocEndDate
     FROM  Table_JOB j
            INNER JOIN Drivers d ON j.driverId = d.driverId
                                    AND j.CollectionDatetime = d.LastAllocStDate ) ,
     T
AS ( SELECT B.NAME ,
            A.Allocation ,
            A.AllocStDate ,
            A.AllocEndDate ,
            A.ClientName ,
            A.ID ,
            IIF(A.AllocStDate <= CAST(GETDATE() AS DATE) AND A.AllocEndDate >= CAST(GETDATE() AS DATE), 'Allocated', NULL) AS OnJob
     FROM   A
            INNER JOIN FieldResource B ON A.DriverID = B.ID ) ,
     Z
AS ( SELECT DISTINCT T.Name ,
            T.Allocation ,
            T.AllocStDate ,
            T.AllocEndDate ,
            IIF(T.OnJob IS NULL, NULL, T.ClientName) AS ClientName ,
            IIF(T.OnJob IS NULL, NULL, T.ID) AS ID ,
            IIF(T.OnJob IS NULL, 'YES', NULL) AS NotAllocated ,
            T.OnJob AS Allocated
     FROM   T )
,CTE1 AS
(
	SELECT   
			 Z.Name ,
			 Z.Allocation, 
			  Z.Allocated ,
			 Z.AllocStDate ,
			 Z.AllocEndDate ,
			 Z.ClientName ,

Open in new window

0
Free Tool: Site Down Detector
LVL 11
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Dear Experts,

I need to process attached excel and insert these records into oracle table. I have below code works for me. Moreover excel's cell(A1) is not readable. Using below code I am reading 1st 3 cells:

                Dim cmdExcel = New OleDbCommand("select * from [" & strWSheetName & "$]", connExcel)
                daExcel.SelectCommand = cmdExcel
                daExcel.Fill(ds, "CUSTOMER")
                dTable1 = ds.Tables(0)

                           strCUST_NAME = dTable1.Rows(0).Item(0).ToString()
                     strS_E_DATE   = dTable1.Rows(1).Item(0).ToString()
                     strDISC_DATE  = dTable1.Rows(2).Item(0).ToString()

Its skipping the R1 row and starting from R2. If I move R1-R3 to R2-R4 then it works fine and I get expected output. Moreover I need expected output without any modification.

Source Records format: Refer Attachment
R1 Customer: SYNTEL                  
R2 Period: 2016-12 - 2017-05                  
R3 Discount Date: 2017-05-31 00:00:00                  
R4                  
R5    PartyName      PartyBix      Ranking
R6       AIG                     Insurance      1232
R7       Humana             Helthcare      3242
R8       Athena             Helthcare      3434
R9       BOA             bank              3431

Expected records in Table

Customer      Period      DiscountDate      PartyName      PartyBix              Ranking
Syntel              2017-05      5/31/2017              AIG                      Insurance      1232
Syntel              2017-05      5/31/2017              Humana              Helthcare      3242
Syntel              2017-05      5/31/2017              Athena              Helthcare      3434
Syntel              2017-05      …
0
Can someone tell me where is the ASP.NET Core Web Application template?
It's there for C# but is missing for VB.NET
1
This code is listing the directories in a given drive.  Why is it duplicating output?

   Private Sub ScanDrive(DriveToScan As DriveInfo)

        Dim path As String = DriveToScan.ToString  '"c:\\"
        Dim searchPattern As String = "*"
        Using sw As New StreamWriter(DirListFile, False)
            Try
                Dim di As DirectoryInfo = New DirectoryInfo(path)
                Dim directories() As DirectoryInfo = di.GetDirectories(searchPattern, SearchOption.TopDirectoryOnly)

                Dim files() As FileInfo = di.GetFiles(searchPattern, SearchOption.TopDirectoryOnly)
                Dim dir As DirectoryInfo
                Dim DirSub As DirectoryInfo
                Dim DirSub2 As DirectoryInfo
                Dim DirSub3 As DirectoryInfo
                Dim DirSub4 As DirectoryInfo
                Dim DirSub5 As DirectoryInfo
                sw.WriteLine("Directory")
                If DriveToScan.IsReady = True Then
                    Try
                        di = New DirectoryInfo(DriveToScan.ToString)
                        directories = di.GetDirectories("*", SearchOption.AllDirectories) 'searchPattern, SearchOption.TopDirectoryOnly)

                        files = di.GetFiles(searchPattern, SearchOption.AllDirectories)
                    Catch ex As Exception
                        If ex.Message.Contains("Access to the path") Then 'carry on
                        Else
                            MsgBox("Page Error.  " & ex.Message

Open in new window

0
Hi I have a typed datatable filled from sql server, bound to 2 gridviews
I need to loop through each row every 5 mins and check if price has changed, if so update it. (the price is coming from an external server)

I did have this on a timer and then loop through each row on same thread but was freezing the UI well it was looping, so now have a background worker to check and update.

the only way i seem to be able to get it to work is to clone the table then loop through rows then on background work completed fill the table again. There must be another way.
If I dont clone the table first the ui freezes and does not recover. Please help.
0
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Chart1.Series("Rate").Points.AddXY("Rowel", 27)
        Me.Chart1.Series("Rate").Points.AddXY("Rona", 24)
        Me.Chart1.Series("Rate").Points.AddXY("Edwin", 28)
        Me.Chart1.Series("Rate").Points.AddXY("Rock", 29)
        Me.Chart1.Series("Rate").Points.AddXY("Ben", 30)
        Me.Chart1.Series("Rate").Points.AddXY("July", 25)
        Me.Chart1.Series("Rate").Points.AddXY("King", 54)
        Me.Chart1.Series("Rate").Points.AddXY("Coby", 64)
        Me.Chart1.Series("Rate").Points.AddXY("Rhian", 74)
        Me.Chart1.Series("Rate").Points.AddXY("Josh", 84)
        Me.Chart1.Series("Rate").Points.AddXY("Ping", 94)
        Me.Chart1.Series("Rate").Points.AddXY("Cardo", 104)
        Me.Chart1.Series("Rate").Points.AddXY("Fact Boy", 234)
        Me.Chart1.Series("Rate").Points.AddXY("Jame", 254)
        Me.Chart1.Series("Rate").Points.AddXY("Bunso", 264)
    End Sub
End Class

Open in new window


That's how I created the chart,
fewaf.JPGProblem is the space of charts How can I Fit this to screen or can I have a scroll bar?
0
I have read everything I can get my hands on about ViewState but can't seem to figure out what I'm doing wrong.

In a sub routine that first and foremost fills a grid, I set the value of two controls and then save those to view state:

                    ViewState.Item("SortKey") = SortKey.Value
                    ViewState.Item("RecId") = RecId.Value

I'm using ViewState because I can't seem to get the control values to persist.

On Page_Load I try to retrieve those values into the controls:
            SortKey.Value = ViewState.Item("SortKey")
            RecId.Value = ViewState.Item("RecId")

This does not work.

What am I missing?


Thanks
0
I want to display the actual winform position on the screen. The current code is the following:

Dim dlgAskInput as New dlgAskInput
'This is where I save the location on the screen
dlgAskInput.Location=New Point (_partfile.showsumamryInputLabelTop, _partfileShowSummaryInputLabelLeft)
dlgAskInput.showDialog(me)

Open in new window


The problem is that it is never applying the Location=New Point (_partfile.showsumamryInputLabelTop, _partfileShowSummaryInputLabelLeft) to the dlgAskInpout form location.

Thanks in advance,
0
Using vb.Net
I would like to output to a text file a list of the file names in a directory.
0
Hi everyone, I have a question, If I have a database (Column for Date_Expiration) how can I use this in VB.net to warn me if the item is reached its expiration date?

OR

How to set this in Stores Procedure in SQL?

Thanks in advance.

Sample
0
Receive 1:1 tech help
LVL 11
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Using  VB.NET Winforms application:  Essentially, I would like to generate a list of GUIDS to exclude from a query (anywhere from about 10 to 1000 GUIDS).  I am looking to determine which of these is most efficient.  Assuming that I have read-only access, can run SQL query code (but not create stored procedures).  

Options:
1)  Dynamically create a SQL WHERE clause to exclude the GUIDS (e.g. "WHERE field1 is NOT IN ('GUID1', 'GUID2", etc...)"
2) Create temporary table in SQL, load the excluded GUIDS, then run the final query against standard tables JOINed with this temporary table
3) Other?
0
Using VB.NET Strong Typed Datasets and/or standard SQL Server Code, is there a way to obfuscate the query so that a SQL statement with multiple table Joins is obfuscated from anyone with access to the SQL Server (reviewing transaction logs, analyzer, etc.)?

1) Assume that the VB.Net Winforms only has access read-only access to the tables (no stored procedure, no "views" access)
2) No LINQ to SQL (too difficult with LEFT/RIGHT joins, and and multiple JOINS)

Essentially, I would like to hide how the tables are joined together, as it has taken a while to get this right.
0
Greetings:

I am a novice when it comes to Microsoft SQL Server things more completed (in my view of things) then a JOIN.

I use Microsoft Visual Studio Pro 2017 and Microsoft SQL Server 2016. I use a VB class to save data to a database table using a stored procedure.

The VB code snippet is as follows:

      Protected Function _SaveLiteral(ByVal _strLiteralId As String,
                              ByVal _blnWebAdminOnly As Boolean,
                              ByVal _blnShow As Boolean,
                              ByVal _fkstrLiteralType As String,
                              ByVal _strDescription As String,
                              ByVal _strLiteral As String) As Boolean

      Dim _cmdBaBLiteral As New SqlCommand
      Dim _objUserData As membershipUser = membership.getuser()

      Dim _intSQLErrorNumber As Int32 = 0
      Dim _intSQLErrorSeverity As Int32 = 0
      Dim _intSQLErrorState As Int32 = 0
      Dim _strSQLErrorProcedure As String = String.Empty
      Dim _intSQLErrorLine As Int32 = 0
      Dim _strSQLErrorMessage As String = String.Empty
      Dim _strUserName As String = String.Empty

      _objBaBAudit.objConnectionStringBabUtilityAdmin = _objConnectionStringBabUtilityAdmin
      _objBaBAudit.objConnectionStringBabUtilityMember = _objConnectionStringBabUtilityMember

      Try
            _cnnBaBLiteral.ConnectionString = _objConnectionStringBabUtilityAdmin
      
            _cmdBaBLiteral.CommandText = "bab_i_Literal"
            _cmdBaBLiteral.CommandType = CommandType.StoredProcedure
            _cmdBaBLiteral.Connection = _cnnBaBLiteral
      
            _cmdBaBLiteral.Parameters.Add("@strLiteralId", SqlDbType.NVarChar, 100).Value = _strLiteralId
      …
0
How can you get the length of a WAV file (seconds or milliseconds) using Visual Basic 2015 and WIN API?
0
I have three tables. Customers and orders and Items.  Each one is hierarchically connected to another. I have databind all the controls and datagrid to binding source.

How to update all the tables by calling binding source.endedit
0
Hi Guys
using vb.net 2017 ...

The following piece of code has been converted from a C# snippet I located  ... I don't speak Spanish and it seems the comments were originally made in that language ... so I have two queries, can someone convert the Spanish comments to English and secondly is the function going to work well ... I've added the Try Catch functionality and would like to improve upon that because I don't know if I am catching the correct errors ...

        Public Function IsEmbeddedAttachment(attachment As Outlook.Attachment) As Boolean

        'Se não for uma imagem nem válida. Retorna direto false
        'if (!DocumentFormat.IsImageFormat(Path.GetExtension(attachment.FileName)))
        '  return false;
        Try

            'Anexos que não são embedded são obrigatóriamente olByValue, porém os embedded podem ser de qualquer tipo
            If (attachment.Type <> Outlook.OlAttachmentType.olByValue) Then
                Return True
            End If

            'Busca a propriedade contentID do anexo. Anexos embedded não precisam necessáriamente gerar um ContentID. Anexos fixos não geram ContentID
            Dim strATTACH_CONTENT_ID As String = attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E").ToString()
            'Busca a propriedade contentLocation. Para que o anexo seja embedded é necessario que essa propriedade esteja vazia ou nulla
            Dim strATTACH_CONTENT_LOCATION As String = 

Open in new window

0

Visual Basic.NET

93K

Solutions

24K

Contributors

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to  Visual Basic pre-2002, it is not the same technology,