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 VB.Net program that uses CrystalReports to print an ID card (CR80).
The viewer shows a portion of a full-size letter format, with horizontal & vertical scroll bars.
What programming / controls are needed to:
1. Resize margins to CR80 ~ 2.13" x 3.38".
2. if necessary, remove scroll bars.

Thank you,

Russ
0
Upgrade your Question Security!
LVL 12
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

SqlStr = "select  ROW_NUMBER() OVER (ORDER BY id) AS [Sno],Employees.EmpID,Employees.contactno,Empname as [Employee Name],WorkType,ClientName,SiteName,Siteschedule.TotalHours AS [Total Working Hours] from Siteschedule inner join clients on clients.clientid=Siteschedule.clientid inner join sites on sites.SiteID=Siteschedule.SiteID  inner join Employees on Employees.EmpID=Siteschedule.empid  where (StartDateValue between " & TxtStartDate.Value.Date.ToOADate & "  and  " & TxtEndDate.Value.Date.ToOADate & ") " & substring
 ambigous column name id
0
can someone provide me an example of how to use an excel spreadsheet as a datasource for a datagrid?
I'm using closedxml but at a lost
Thanks!
0
When I compile someone c# code, I got the following warning.  What do I need to resolve this? Any idea?

The primary reference "xxxConfiguration" could not be resolved because it has an indirect dependency on the assembly "xxxAsync, Version=7.05.101.0, Culture=neutral, PublicKeyToken=58aa7495915e0000" which was built against the ".NETFramework,Version=v4.6" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
0
I want to have a punch in / out functionality by using just a barcode reader to scan the employee barcode then deal with it in the database.

We have only one screen (And the customer does not want to have multi-screens), however), The customer wants to let each employee punch in by scanning his card while the main user is using the application. How can I do that (As if I have 2 separate computers one for punch in/out and the other is for the normal cashier and system work?):

1. Is there any global application event which is triggered by keyboard regardless of the active form, and in focus control?
2. Is there any trigger that allows the barcode scanning to start a quick application to perform the functionality and close itself?
3. Is there a possibility to have the main application open, and a punchInOUT application also running (only one screen with one text box), but make the barcode scanning affecting only the punchINOUT application?
4. Any brilliant idea to allow this functionality

Thanks in Advance for help. Please help in VB.NET (I am using VS2010)
0
how do you update a single cell using closedxml ? When i use this code, it takes and overwrites the entire file not just that one cell.  
I can use interop to do this but I was wanting to try closedxml to learn.

here is my code that should only update row 1 column 2
 Dim xlworkbook As New XLWorkbook("c:\testcode\exceltest.xlsx")
        Dim xlworksheet = xlworkbook.Worksheet(1)

        xlworksheet.Cells(1, 2).Value = "testing1"
        xlworkbook.Save()

Open in new window

0
Hi,
I've got two application in vb.net: One with a form for authentication (App A) and one wich require authentication (App B) to access it
Everything works fine, but it happens this when the session is outdated (ex. i leave App B opened on a page) :

-> i trigger whatever control on the opened App B
->This cause a page load that, checking for login with My.User.IsAuthenticated, redirect me to App A
-> App A ask me to login, and from the logged in menu i select to access App B
-> On PageLoad, App B chek again for My.User.IsAuthenticated which return false, even if i logged on App A

So i cannot access App B anymore if i don't clear the cache
This happens when the session is outdated, but not if i login/logoff manually

Is there some settings App User that i should check?
0
Playing AVI files in a picture box from dll. .OCX and other files in Visual Basic 10 Express.
I would like to have a complete code that reproduces. avi files in the. dll. OCX and other files in a PictureBox written in Visual Basic 2010 Express.
So to speak for example that it reproduces an AVI file while it is copying a file (I have the code in Visual Basic 6 and I cannot get it to work in Visual Basic 2010 Express).
From what I could understand by reading the various forums in Internet there is also the possibility of embedding an AVI file by transforming it into a resource and uploading it to Visual Basic 10 Express, if it were so it would be good to know how to create that resource, embed it in Visual Basic 10 Express and play it in a picture box while the application is working (always with full code).
is clear transparency effect and continuous play.
I would want complete code to download with any clarifications.
Without wasting time writing code I'm attaching a file containing a working Visual Basic 6 program that I've tried to convert to Visual Basic 10 express in all ways, you might see if it did you and send it back to Visual Basic 10 Express.
Thank you.
0
I have an access database that I am converting to a vb.net project.  There are a few lines of script that are causing issues.  Mostly the DLookup conversion.  Any help at converting this script would be most appreciated.  Thank you in advance!

Here is the original VBA code:

Private Sub Form_Timer()
'On Error GoTo ErrTrap:
    Dim DB As Database
    Dim rs As Recordset
    Dim count As Integer
    Dim displayCount As Integer
    Dim formToOpen As String
    Dim stopTime As Date
    Dim nowTime As Date
    Dim WinWnd As Long
   
    'Determine if a member of management has set an alert message. If not, continue normal operations
    If DLookup("Alert", "AlertMessage", "Alert > 0") <> "" Then
       
        'Open the alert message
        DoCmd.OpenForm ("frmMessage")
       
    Else
   
        Call Form_Query
       
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       
        'Run the NRFT screen for 1 minute, then open the safety message
        If runCount = 2 Then
            DoCmd.OpenForm ("Form1")
        End If
       
        'Close the safety message after 1 minute
        If runCount = 5 Then
            DoCmd.Close acForm, "Form1"
        End If
       

           
        If runCount >= 8 Then
       
       
            'Loop through all rows in the Content table where Active is set to yes
            'For Count = 0 To DCount("Active", "Content", …
0
I am using vs 2013 vb.net. I need Microsoft Outlook Object Library 15.0.
It is not list as a COM Objects.  How do I get the Library included.  

14.0 is list but is cannot be loaded.

I need to load it for application that will update users Outlook Calendar.

Isaac
0
Cloud Class® Course: Python 3 Fundamentals
LVL 12
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Code below is supposed to go through a list of word docs, all docs being printed are blank.

Any idea what I could be missing? For now I'm only printing 1 page docs. Would anyone be able to incorporate StreamReader code into there for me? I'm reading a print guide at the moment, would love ideas.

 Imports system
Imports system.Windows
Imports System.Object
Imports System.Windows.Forms


Module Module1


    Sub Main()
         
         Dim files() as String = IO.Directory.GetFiles("C:\Users\Hares1\Desktop\PROGRAMS\DWG")
    
    For Each file In files
       Dim psi As New ProcessStartInfo(file)    
      Try

             
        psi.Verb = "printto"       
        psi.UseShellExecute = True
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.CreateNoWindow = True 
        Process.Start(psi).WaitForExit(5000)          
      Catch ex As Exception
        Console.WriteLine(File)               
      End Try	  
	Next file	

	
	
	Console.WriteLine("Done.")
	Console.ReadKey()
    End Sub

End Module

Open in new window

0
Hi

In my ASP.net web app I need to email a pdf document containing information about a purchase order.
How would I build a neatly formatted pdf document using VB.net?
0
Code below only prints 1 doc, the first one

I have a few files in my path, but it wont print the rest...
Any ideas?

Imports System
Imports System.IO
 Imports System.Windows.Forms
 Imports System.Windows.Forms.Form
Imports System.Windows.Forms.PrintPreviewDialog




Module Module1


    Sub Main()
        Dim PrintDialog1 As New PrintDialog()
          Dim files() as String = IO.Directory.GetFiles("\\sv-fs03\users$\..........\dwg printer")
    For Each file In files
               
      Try

                 Dim psi As New ProcessStartInfo(file)
        psi.Verb = "print"       
        psi.UseShellExecute = True
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.CreateNoWindow = True 
        Process.Start(psi).WaitForExit(5000)          
      Catch ex As Exception
        Console.WriteLine(File)               
      End Try   
Next file
        Console.WriteLine("Done.")
Console.ReadKey

        
     

    End Sub

End Module

Open in new window

0
I would like a script or program where I could specify a server and a top level share and the script will walk the entire structure including all sub directories and will generate a report as a.csv file with the information and format shown in the attached screen shot. I only want explicit permissions shown, not inherited permissions.
This doesn't have to be PowerShell. It could be .vbs or other language. I just need to get the output in the format I'm looking for.
0
I have code to write to a file, but having trouble with appending.  I want the first line not to append, but the remaining lines to append.  I have this code...

Dim FILE_NAME As String = "\\server\folder\filename.txt"
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
'My loop starts
                If i = 1 Then '2nd line to be written
                    objWriter = New System.IO.StreamWriter(FILE_NAME, True)
               End If
objWriter.WriteLine(strLineOfText)
'My loop ends
objWriter.Close()

Open in new window


Obviously I can't change the objWriter within the If statement, but I can't figure out how to get the append to work.  How can I get this code to work, or is there a better way to write and append to a file?
0
how do you prefix 0s to a string.
for example I have a string that can be
1
2
3
12
110

i want it to be
001
002
003
012
110

how can i do this in code? I get how i can do the singles but how do i do the 2 digit and 3 digit?
0
I have the following code which is working perfectly:

Public Sub MakeThisConfidential()
Application.ActiveInspector.CurrentItem.Sensitivity = olConfidential
Application.ActiveInspector.CurrentItem.Save
' MyMsg = MsgBox(Prompt, 0, "This message has been marked Confidential and will be encrypted by Fusemail")
MyMsg = MsgBox("Click OK to accept status" & vbCrLf & "This will encrypt the Current Message using fusemail", 0, "This message has been marked Confidential")
End Sub

Sub ToggleSensitivity()
    If ActiveInspector.CurrentItem.Sensitivity = olConfidential Then
        ActiveInspector.CurrentItem.Sensitivity = olNormal
        MyMsg = MsgBox("Click OK to accept status" & vbCrLf & "This will NOT encrypt the Current Message using fusemail", 0, "This message has been marked Normal")
    Else
        ActiveInspector.CurrentItem.Sensitivity = olConfidential
        MyMsg = MsgBox("Click OK to accept status" & vbCrLf & "This will encrypt the Current Message using fusemail", 0, "This message has been marked as Confidential")
    End If
End Sub

Open in new window


I have attached it to 2 separate buttons
I want to be able to run the macros and change the current button image. The image is added by the outlook interface:
In the New Mail window:
File - Options - Customise Ribbon - Main Tabs - New Mail Message
There is a group in here which has buttons with the macro's attached
0
I need one Print Dialog() box for my entire batch of documents in a given folder. Currently I'm looping through each file in a folder (I'd like to maintain this, because i'll be programatically modifying files), however I want to be able to change the print settings once and use it for all files ~ the code below works for looping and printing, however I'm not sure where to include PrintDialog()   ~ I'm thinking something along the lines of passing the entire subroutine to printdialogue as a parameter.  For now I'd like to avoid Click events, any thoughts, ideas?

Any ideas?

 Imports system
Imports system.Windows
Imports System.Object
Imports System.Windows.Forms


Module Module1


    Sub Main()
         
         Dim files() as String = IO.Directory.GetFiles("C:\Users\Hares1\Desktop\PROGRAMS\DWG")
    
    For Each file In files
               
      Try

                 Dim psi As New ProcessStartInfo(file)
        psi.Verb = "print"       
        psi.UseShellExecute = True
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.CreateNoWindow = True 
        Process.Start(psi).WaitForExit(5000)          
      Catch ex As Exception
        Console.WriteLine(File)               
      End Try   
Next file

 
 
Console.WriteLine("Done.")
Console.ReadKey()
    End Sub

End Module

Open in new window



Worst case scenario could I include the aboive code in its own class, and pass it as a parameter to PrintDialog()   ??
0
Hello,

Im relative new on Programming using VB.NET but, I want to know how can I use a webservice on Windows Forms app, I have a REST API.

Any idea of how can I do this requirement?.

Regards,
0
Cloud Class® Course: MCSA MCSE Windows Server 2012
LVL 12
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

So I've written the below code, which prints all the files in my directory ~ problem is everything but the first document is blank ~ basically it prints the first document and ret are blank

I'm thinking it has something to do with filepath, and that I may have to switch filepath with a variable defined for each document...?

Would anyone be able to troubleshoot my code, so as I can print each file instead of just the first file, with the others being blank...?

Thanks!

 Imports system
Imports system.Windows
Imports System.Object
Imports System.Windows.Forms

Module Module1
   


            Sub Main()
                                '///Dim PrintDialog1 As New PrintDialog()

                                '///PrintDialog1.ShowDialog()
         For EACH filePath In IO.Directory.GetFiles("......Desktop\PROGRAMS\DWG")
    Try
        Dim psi As New ProcessStartInfo(filePath)
 
        If 1=1

                

            psi.Verb = "print"
                  
                  

        
            psi.UseShellExecute = True
            psi.WindowStyle = ProcessWindowStyle.Hidden
            psi.CreateNoWindow = True
 
            Process.Start(psi).WaitForExit(5000)

          
        Else
            Console.WriteLine("No 'print' verb associated with file extension " & IO.Path.GetExtension(filePath))
        End If
    Catch ex As Exception
        Console.WriteLine(ex.ToString(filepath))
               
    End Try
          
Next
       End Sub


End Module

Open in new window

0
I have a windows forms application. The form has a few buttons on it that will open other forms. The other forms have text input controls on them.

In a windows forms application , is their a way to cache windows forms data ? In an asp.net application, this can easily be done by saving the data to a cache object, or saving it in the session variable. However my application is a VB.net desktop application.

I thought about maybe just saving everything in a list, and then saving that list of data to a text file, and just let the text file on disk to serve as my caching mechanism.

There has to be a better way though, because I just need to save data in memory. So for a Windows Forms application, is there a way to cache the data into memory? So that I can reuse it later?
0
Hello Experts,

DocumentBeforeSave, DocumentBeforeClose, DocumentChange functionality not working in .docx, but works in .dotm.

How does one make it work?  Help!

The attached file will need its extension changed from .zip to .dotm...
ECT.zip
0
I want to update outlook calendar using the code below:

 Private Sub Set_Calendar()
        Dim appointment As Outlook.AppointmentItem = Nothing
        Dim recipients As Outlook.Recipients = Nothing
        Dim recipient As Outlook.Recipient = Nothing
       
        Try
             
            appointment = CType(OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
            appointment.Subject = "A meeting"
            appointment.Start = DateTime.Now.AddHours(1)
            appointment.Duration = 60
            appointment.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
            recipients = appointment.Recipients
            recipient = recipients.Add("Isaac Johnson")
            recipient.Type = CInt(Outlook.OlMeetingRecipientType.olRequired)
            If recipient.Resolve() Then appointment.Send()
        Finally
            If recipient IsNot Nothing Then Marshal.ReleaseComObject(recipient)
            If recipients IsNot Nothing Then Marshal.ReleaseComObject(recipients)
            If appointment IsNot Nothing Then Marshal.ReleaseComObject(appointment)
        End Try
    End Sub

I am getting a null reference  exception at this line of code:
appointment = CType(OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)

I am using vb.net
I've tried I few changes but I am stuck.

I need help asap..  I even tried removing the line of code but the line that follows …
0
Is there a way to recover the password on a Word VBA Project using programming code? My file format is .dot. A Lot of recovery tools available in online but need to pay for those products I'm a student not able to pay so I need to recover or view my VBA project .dot file forgot password using code. Is it possible in code using .net programming or VBA code or any other programming codes?
0
Ok, so the below code goes through the files in a folder and prints them ~

What I want to do is for the code to read the docs 1 by 1, since there are problem docs, and thats why i'm creating this~

I'm going to wait for a sleep timer on the docs that wont print ~

hence why I want the process to run once for each doc

How would i run the PSI process once for each doc (in this case filepath), then loop back to the beginning of the process...?
Module Module1


            Sub Main()
  
         For Each filePath In IO.Directory.GetFiles("......\Desktop\PROGRAMS\DWG")
    Try
        Dim psi As New ProcessStartInfo(filePath)
 
        If 1=1

                

            psi.Verb = "print"

                  

        
            psi.UseShellExecute = True
            psi.WindowStyle = ProcessWindowStyle.Hidden
            psi.CreateNoWindow = True
 
            Process.Start(psi).WaitForExit(5000)

          
        Else
            Console.WriteLine("No 'print' verb associated with file extension " & IO.Path.GetExtension(filePath))
        End If
    Catch ex As Exception
        Console.WriteLine(ex.ToString(filepath))
               
    End Try
             Console.ReadKey()
Next
       End Sub


End Module



  
      

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,