Visual Basic.NET

94K

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've done some research and I know this is a common issue. There are several reasons why this could be happening. But let me lay out what the app does and maybe narrow the problem down.

I'm very newbish at programming. So much so that all the VB app does is run a batch file upon a button click.

The batch files contain a command that determines if the processor is 64bit or 32bit:

if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT

Open in new window


When I run my application in Debug mode the batch files run perfectly fine. Everything executes and completes. However, when I go to release the app and run the EXE file it seems like the batch files are ignoring the processor architecture line. The file doesn't go to the 64BIT section and just processes everything in line. Or it's not processing the 64 bit line correctly and it's going to the 32bit section.

Here is a snippet of code from one of the buttons:

Private Sub RunningButton_Click(ByVal sender As System.Object, e As EventArgs) Handles RunningButton.Click
        Dim proc As Process = Nothing
        Try
            Dim batDir As String = String.Format("\\remoteserver\software\batch_files\inhouseapp fixes\")
            proc = New Process()
            proc.StartInfo.WorkingDirectory = batDir
            proc.StartInfo.FileName = "inhouseapp Already Running.bat"
            proc.StartInfo.CreateNoWindow = False
            proc.Start()
            proc.WaitForExit()
            'MessageBox.Show("Bat file 

Open in new window

0
Hello. I have a form where I have to make panels visible or invisible based on the radio button or checkbox selected.  The problem is, when you click on any choices the focus goes to the top of the page.  So when filling out the form you lose your place once you start to scroll because each time you click on one of the elements the focus goes back to the top of the page.  How can I stop this?
0
I am loading data from a SQLDataReader...

I need to see if less than 24 hours has passed since the record was created.

If more than 24 hours has passed set bContinue = False

I can populate a label with this code
lblMessage.Text = "Now: " + Date.Now() + "<br /><br />Date Added: " + CDate(dR3("DateAdded").ToString())
0
Help me, how do i refer to an element in a list through a variable name value

I have created a list of a structure in vb.net

now a would want to refer to an element in a list through a variable name value

example (sorry i don't have the real code with me here)

Public Structure staff
        Public staffname As String
        Public departmentid As Long
End Structure

dim val as "staffname"

stafflist  is the list obtained from the Structure above.

i want to get something like currentstaffname = stafflist(val) where val is equal to  "staffname"

I am using vb.net

Anthony
0
Is there a way with EWS / PowerShell to get this done?
To mark the folder as undeletable?


Thank you.
0
Hi there.

I'm working on rebuilding a website in VB.NET from classic asp. I had this:

<!--#include file="checkcook.asp"-->

on pages that required a specific cookie. If not present, then the user is transferred to another page like this:

<%
strUserName = Request.Cookies("testcookie")("User")
If strUserName = "" Then
	Response.Redirect"nocook.asp?Message=You_have_no_access_to_this_page"
End If
%>

Open in new window


How do I implement a similar feature in VB.NET? I suppose this goes only in the code behind files??

Best regards

Ulrich
0
Hi Folks,

I'm trying to make a parser from text to Excel.  Some of the text, I know the number of entries there will be and so I can use an array to pull in the data and simply assign the array to the excel range.  No problem.  However, for some data, I don't necessarily know the number of entries and so I am using a list instead of an array.  So how do I quickly get the list into the excel spreadsheet?  I can't seem to find anything.

Here is the example for an array.  Had to make it 2 dimensional (why I don't know), and then set all the empty cells to blank ("").  But then when you set the range = the array, it works fine and is fast.  This is what I need because I don't want to iterate cell by cell.  I'd be waiting for days.

xlWS.Range(xlWS.Cells(row + 1, column), xlWS.Cells(row + 1 + MyInfo(0).Length, column)).Value2 = MyInfo

Open in new window


The below is the list and does not work.

xlWS.Range(xlWS.Cells(row + 1, column), xlWS.Cells(row + strMyList.Count)).Value2 = strMyList

Open in new window


Any insight is most appreciated.
0
I just recently started having an issue in Visual Studio when running debug mode for a vb.net application that when I try and step through the code (F11) I am now getting a pop up error (see attached) string.cs not found

I have not been able to locate a solution to this online so I'm turning to this group to see if there has been any similar incidents or recommended solutions.
2017-10-06_15-14-45.png
0
Hey all,

I've been scratching my head as to why text being displayed isn't showing as a double precision decimal. I am getting the total hours worked by an employee by subtracting datetime values. I am needing a display as 1.00 and not just 1. Here is inline code for this. Keep in mind I did not write this I am trying to make some changes to this code until the application can be rewritten.

 <td><asp:Label ID="lblHours" runat="server" Text='<%# If(Eval("EndTime") = "", "", Math.Round((Convert.ToDateTime(Eval("EndTime")) - Convert.ToDateTime(Eval("StartTime"))).TotalHours(),2))  %>'

Open in new window

0
I have a text file that is separated by periods.  I want to grab everything before the 14th period (including the previous periods) and everything after the 18th period (including the remaining periods.  I could use str.split and then join the first 14 back together and the last 4 at the end, but I think there is an easier way.

Maybe using substring?

Let me use the following as an example...

a1.b1.c1.d1.e1.f1.g1.h1.i1.j1.k1.l1.m1.n1.p1.q1.r1.s1.t1.u1.v1.w1.

So what I would like is to grab everything from a1 to n1 including the periods and then everything from t1 to w1 including the periods.  Is there an easy way to do this?

Thanks!
0
Is there a way to grey out every other week.  i have code to select only friday, but this is for a payroll and i only want the user to select  every other based on the year.  i dont want to hard code the  dates because i want it to roll over every year.  I would like it for example to select only  9/1/2017 or 9/15/2017 etc....  due to extra days in months and leap  years etc.. is there a way to do this?

thanks
0
Hi,

Im using this code:
        Dim SearchForm As New Form
        SearchForm.Show()
        SearchForm.StartPosition = FormStartPosition.CenterScreen

Open in new window

i want to make that as search form like this on the picture attached,
AttachedHow can I design that new form?
0
The following is my code

Dim Txt as string
Dim counter = My.Computer.FileSystem.GetFiles("C:\Test", FileIO.SearchOption.SearchTopLevelOnly, "1234*.txt")
Txt="0000" &  counter

I am getting
BC30311     value of type 'readonlycollection(of string)' cannot be converted to 'string'

Any idea how to convert (counter) to a format that can be attached using (&)
0
        Dim cmd As MySqlCommand = conn.CreateCommand()
        cmd.CommandText = "SELECT * FROM rsv.tbl_accounts where user_name = '" & TextBox6.Text & "'"
        cmd.CommandType = CommandType.Text
        conn.Close()
        conn.Open()
        Dim count = cmd.ExecuteScalar()
        cmd.Clone()
        Label21.Text = count

Open in new window


About the above code, I want to display the user_name in Label21.text but it display the first column of the table from database because the user_registration_date is in the first column and the user_name is on the 3rd column. How can I display it? The 'rowelv' in Label21.text ???

Thanks

Sample SQL
0
I have an iframe in a web page that needs to listen for a message from a child page within an iframe. I'm having an issue making this happen. Anyone have a clue why?

Parent...
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        // Create IE + others compatible event handler
        var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
        var eventer = window[eventMethod];
        var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";

        // Listen to message from child window
        eventer(messageEvent, function (e) {
            console.log('parent received message!:  ', e.data);
        }, false);
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <iframe src="child.aspx"></iframe>
    </div>
    </form>
</body>
</html>

Child...
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        // Every two seconds....
        function sendMessage() {
            // Send the message "Hello" to the parent window
            // ...if the domain is still "davidwalsh.name"
            parent.postMessage("Hello", "http://localhost:49646/Child.aspx");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Hello world. This is the child.
    </div>
    </form>
</body>…
0
Hello Experts,
When i use the code below(LoadXmlInv()) in validating events of every combo box my App. hang up the cursor go to the next combo box after many seconds (long time)
I've this Sub to load saved items to a list of  combo boxes
 Sub LoadXmlInv()
        ''##For Sorting the items in the combo box and in the same time loading the Xml file
        cbxMedH1.Items.AddRange(XElement.Load(Application.StartupPath + "\Investigations.xml").
        <Invest>.Select(Function(n) n.Value).OrderBy(Function(s) s).ToArray())
        cbxMedH2.Items.AddRange(XElement.Load(Application.StartupPath + "\Investigations.xml").
        <Invest>.Select(Function(n) n.Value).OrderBy(Function(s) s).ToArray())
        cbxMedH3.Items.AddRange(XElement.Load(Application.StartupPath + "\Investigations.xml").
        <Invest>.Select(Function(n) n.Value).OrderBy(Function(s) s).ToArray())
        cbxSurH1.Items.AddRange(XElement.Load(Application.StartupPath + "\Investigations.xml").
        <Invest>.Select(Function(n) n.Value).OrderBy(Function(s) s).ToArray())
        cbxSurH2.Items.AddRange(XElement.Load(Application.StartupPath + "\Investigations.xml").
        <Invest>.Select(Function(n) n.Value).OrderBy(Function(s) s).ToArray())
        cbxSurH3.Items.AddRange(XElement.Load(Application.StartupPath + "\Investigations.xml").
        <Invest>.Select(Function(n) n.Value).OrderBy(Function(s) s).ToArray())
        cbxGynH1.Items.AddRange(XElement.Load(Application.StartupPath + 

Open in new window

0
Hi I ma trying to use the webbrowser to load the following site:
https://uk.tradingview.com/chart/?symbol=NASDAQ:AAPL

But just get page says browser not supported, which and taking it its a javascript issue. I did try eo.webbrowser that does work but $700 is too much.

Is there a way to get ms.webbrowser to work. I have read if i edit the registry you can but not really a production way of doing it.
0
Hi Guys,
I have asp.net mvc 4 application and I would like to write error log events to my application event log at windows computer.

I did write this method below which write logs just if I get an exception in the controller:

Global.asax
 Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

        Dim ErrorDescription As String = Server.GetLastError.ToString

        'Creation of event log if it does not exist  
        Dim EventLogName As String = "Tab Web Access"
        If (Not EventLog.SourceExists(EventLogName)) Then
            EventLog.CreateEventSource(EventLogName, EventLogName)
        End If

        ' Inserting into event log
        Dim Log As New EventLog()
        Log.Source = EventLogName
        Log.WriteEntry(ErrorDescription, EventLogEntryType.Error)

    End Sub

Open in new window


Now I have another project which return data from sql server and I call methods from this project from my controller.
The issue is when something fail in the other project the method I wrote in the global.asax doesn't instantiate and I don't see any log in the windows event log.

Please, can somebody suggest how can I approach this goal.

Thank you.
0
Hi, experts
I have win App. using VS 2015 and Access 2013 and i want to make a demo (i.e Open this App 100 times, 60 times something like that). I've a code that make my App. lock after a certain date, but i'm not sure if the users can change the date of their machines they will be able to break my protection. So that i think that open my App. number of certain times more efficient than determine a fixed date to expire.
Any suggestions will be appreciated.......thanks in advance
0
I was thinking to make a program that sends email from my datagrid view or textbox and I don''t know how to start
0
Is it possible to send the data from my program to excel? any Tips and link for tutorial please and thank you.

This is my program
VB
I want the details to automatic or by click send the values from this program to my excel file.
This is my excel file!
ExcelIm trying to find same in internet but can't get what exactly what I wanted to do.
0
Good day,

Can you take a look of my code, why isn't working? I'm trying to make my customize Form and I put a picture box for Minimize, maximize/restore and close buttons...

    Private Sub PictureBox7_Click(sender As Object, e As EventArgs) Handles PictureBox7.Click
        If Me.WindowState = FormWindowState.Maximized Then
            Me.Size = New Size(1352, 724)
        Else
            WindowState = FormWindowState.Maximized
        End If
    End Sub

Open in new window

0
I have a form that opens maximized, but the form is off to the left side with all the gray space to the right.  Is there a way I can center the form within the window?  I'm not talking about centering it on the desktop, I just want it centered within it's own window.
0
Hi,

Need suggestions regarding building a new B2C e-commerce website. We are into to trading business and our main items of sale are books.

Currently our company's official website is hosted as per following specifications :

1) Developed using ASP.NET 2.0 with VB.NET as code behind.

2) Hosted using IIS 7.

3) Back-end : SQL Server 2008

4) OS: Windows Server Datacenter OS

We need to completely revamp our existing website. While we would like to incorporate completely new approach and features, we would also like to keep some of the old features as legacy functions.

Looking at the future perspective (10-15 Years), I need a suggestion as to what development technology platform (ASP.NET or otherwise) and the server side and client programming languages(PHP, C# etc.) should we adopt to develop this new website which should be able to adapt in following terms :

1) Scalability

2) Ease of inclusion or incorporation of new technical concepts and features.

3) Easy maintenance

4) Fast development

Though we would like to retain SQL Server (current or any upper version) as our backend, suggestions are welcome.

Thanks in advance.
0
I have a 9 page pdf document. I am trying to add a watermark to pages 1,3,5,7,8,9. See my code below, I'm having issues adding the image to the page sequence.

Using inputPdfStream As Stream = New FileStream(Server.MapPath("~") + "/Application.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
      Using inputImageStream As Stream = New FileStream(Server.MapPath("~") + "/Signature.png", FileMode.Open, FileAccess.Read, FileShare.Read)
            Using outputPdfStream As Stream = New FileStream(Server.MapPath("~") + "/Application2.pdf", FileMode.Create, FileAccess.Write, FileShare.None)
                  Dim reader = New PdfReader(inputPdfStream)
                  Dim stamper = New PdfStamper(reader, outputPdfStream)
                  Dim pdfContentByte = stamper.GetOverContent(1)

                  Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(inputImageStream)
                  Dim pages As Integer = reader.NumberOfPages
                  For i As Integer = 1 To pages

                        image.SetAbsolutePosition(100, 100)
                        pdfContentByte.AddImage(image)

                  Next
                  stamper.Close()
            End Using
      End Using
End Using
0

Visual Basic.NET

94K

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,