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

Hi

I am building a VB.net app that pulls data from an API using JSON in the procedure shown further on.
I have now been asked to edit the data using a POST and the following JSON string. What VB.net code would I use to do this? Thanks

[
{"LineID":2,"EmployeeID":"4720","EmployeeName":"Claire ","LogDate":"19 Apr 2019","Hours":2,"EmplyeeWorkType":"Work","Co_ID":6},
{"LineID":0,"EmployeeID":"4742","EmployeeName":"Will         Pretorius","LogDate":"19 Apr 2019","Hours":4,"EmplyeeWorkType":"Work","Co_ID":6}
]

 Function Get_MB_Employees_Hours(StoreID As Integer, Optional emplyeeID As Integer = 0) As List(Of EmployeeHours)

        Try
            'First declare the master API URL:
            Dim url As String = "http://www.xxxxxxxx.com/platform/api/"
            'Dim url As String = "http://www.xxxxxxxx.com/platform/api/EmployeeHours"

            'When calling the API you are calling a method or function
            Dim API_Method As String = "EmployeeHours"

            'On there API we passthrough an additional header for the authorisation, 
            'this Is the username And password combined And split with :

            Dim Auth As String = Me.txtUsername.Text & ":" & Me.txtPassword.Text

            Dim EmpParam As String
            If emplyeeID = 0 Then
                EmpParam = ""
            Else
                EmpParam = emplyeeID
            End If

            Dim oStartDate As String = Me.Calendar1.SelectedDate.ToString("dd MMM yyyy")
       

Open in new window

0
I am trying to create a Trial Balance output report (Maybe crystal reports) in VB.NET desktop application.

There are 5 different tables to retrieve the data from.  I have attached the VB.net Code.

My thought is to create a view within the SQL database that will do everything that the code attached will do.

My questions are:

Is this possible?

Can someone please help me?
TrialBalCode.docx
0
Hello,

I wonder is there any easy way to get number of dots;

$G_Name1.$B_Name2.$C_Name3.$N_Name4

' output dot number: 3
' last value: $N_Name4
' other values : $G_Name1.$B_Name2.$C_Name3

Any help would be great thank you.
0
Hi

In my ASP.net web app I use the following code to create a link that will appear in emails. I want the link to look more like a button, possibly with
a gradient affect. How would I do this? Thanks

            oLink = "http://xxxxx.azurewebsites.net/progressive_report?oLoadShaft=" & Replace(oShaft, " ", "%20")
            oHBody = oHBody & "<br>"
            oHBody = oHBody & "<a href=" & oLink & ">" & oShaftandRegion & "</a>"
            oHBody = oHBody & "<br>"

Open in new window

0
What tools are needed for .net mobile device development and where can I find some really good tutorials?

I'm thinking Xamarin, since it's write once, and C#. Does it also allow VB.NET?

Thanks!
0
How can i organize the below value via type.val ascending or descending. Any help would be grateful

 
       Dim getOVnames = From ov In list
                         Group ov By Type = ov.type.val Into Group
                         Select Type, ForceGroup = Group

Open in new window

0
Hi. In my VB.net code I use the following SQL statement. I need to build a further SQL statement where the [Date] is Month to Date
            S = "Select convert(varchar(11),[Performance].[Date],113) As [Date],[Performance].[Shaft], Sum([Performance].[Drilled Total]) As Metres,Cast([vShafts_StartDate].[Target] As Money) * Count(DISTINCT [Performance].[Date]) As Target, Sum([Drilled Total])/(Count(DISTINCT [Date])*Count(DISTINCT [Machine Number])) As [Ave M/Mach/Shift], Sum([Performance].[Delay Hours 1]) As Delays"
            S = S & ", Sum(Case When [Delay Code 1] In('drill','dwr','evd','mhd','mmd','msd','s54','sdt') Then [Delay Hours 1] End) As [Mine Delays]"
            S = S & ", Sum(Case When [Delay Code 1] In('led','lhd','lmd','lpd','rig','tp') Then [Delay Hours 1] End) As [Lesedi Delays]"
            S = S & " FROM [Performance] Inner Join [vShafts_StartDate] On [Performance].[Shaft] = [vShafts_StartDate].[Shaft]"
            S = S & " WHERE [Date] >= " & oUseFromDate & " And [Date] <= '" & Me.Calendar2.SelectedDate.ToString("dd MMM yyyy") & "'And [Performance].[Shaft] = '" & Me.DropDownList_Shafts.Text & "'"
            S = S & " GROUP BY [Performance].[Date],[Performance].Shaft,[vShafts_StartDate].[Target]"

Open in new window

0
I want to read and XML file and get specific information.  Currently, my VB.net code is:

        Dim xmlDoc As New XmlDocument()
        xmlDoc.Load(vFileName)

        Dim DocNodes As XmlNodeList = xmlDoc.DocumentElement.SelectNodes(vDoc )

My variable  vDoc = "/Transport/BOL/Sheets/Doc[@type='Invoice']".

This works fine except when I have two with the same type and I only want to read the one marked valid.
XML = Doc type="Invoice" charge ="Standard" isValid="true"

I tried "/Transport/BOL/Sheets/Doc[@type='Invoice' @isValid='true']" but that did not work.  Any ideas?

How do I limit my node to the two characteristics?
0
I have seen VB Code samples on how to add a User to a AD Group but not a AD Computer added to a AD Group.
I am decent at VB.NET and I am learning Powershell
This is something I found does anyone know how to tweak it to have a computer get added tom a AD Group
PS C:\> Add-ADGroupMember -Identity SvcAccPSOGroup -Members SQL01,SQL02

Open in new window

0
Hi

In my ASP.net chart I used the following VB.net code in the pie chart series
The problem is that it substantially shrunk the size of the actual chart
Is there a way to stop the actual chart from shrinking so much?
I have included an image of the chart with the code and below that without it.
Please ignore the different percentages. I used two different data sets but the shrinkage was the same

       series1.Label = "#VALX (#PERCENT)"
            series1("PieLabelStyle") = "Outside"
            series1("PieStartAngle") = "45"

Open in new window


1
2
0
I'm getting some lists via COM-Interface from third part tool. It gives me some lists with same size but some of the items are comes as empty according to configuration.

For example i'm getting 3 list from tool like below.

Dim list1 As List(Of String) = ("Fx", "Fy", "Fz", "Fm", " ", "Dy", "Dz", " ", "Ax", " ", "Az")

Dim list2 As List(Of String) = ("Fx", "Fy", "Fz", " ", "Dx", "Dy", "Dz", "Dm", " ", " ", " ")

Dim list2 As List(Of String) = ("Fx", "Fy", "Fz", "Fm", " ", " ", "Dz", " ", " ", "Ay", "Az")

Open in new window

And finally i'd like to get a final list like below.

Dim allList As List(Of String) = ("Fx", "Fy", "Fz", "Fm", "Dx", "Dy", "Dz", "Dm", "Ax", "Ay", "Az")

Open in new window

As you can see all items same position but missing parts are filled from another lists.

Any help would be grateful.

Thanks.
0
Hello,

I'm using below code to add values to datagridviews according to their types.

                For Each force In forceList
                    Dim tp As TabPage = DirectCast(tabCtrl.Controls("tabCheckForceOut_" & force.type.val.ToString), TabPage)
                    Dim dgv As DataGridView = DirectCast(tp.Controls("dgvCheckForceOut_" & force.type.val.ToString), DataGridView)
                    dgv.Rows.Add(force.parent, force.name)
                Next

Open in new window


I have also function like below and it's returning a list of double.

        Private Function EvaluateForce(ByVal xObj As IScrForce) As List(Of Double)
            Dim ovNumber As Integer = xObj.getNumOv
            Dim resList As New List(Of Double)
            For i As Integer = 1 To ovNumber
                resList.Add(CoreGlobal.Base.Server.Spck.Slv.eval("FORCEOV(" + xObj.fullName + "," & i & ")"))
            Next
            Return resList
        End Function

Open in new window


In normally if the output value number is certain for each type of force it'll be easy for me to add rows like that.

Dim result As List (Of Double) = EvaluateForce(force)
dgv.Rows.Add(force.parent, force.name, result.item(0), result.item(1), result.item(2))

Open in new window


As you can see if i know "result" list has 3 items it's easy for me to add.

But if i dont know the list size/ item number how is it possible to add row to DataGridView?

Thank you.
0
Hello,

I'm using below code to generate datagridviews in some tabs.After that i'd like to access them but i dont know how is it possible?

        Dim list As List(Of IScrForce) = ModelBase.GetForceList(CType(mdl, IScrModelBase), True)

        Dim ftypes = From l In list
                     Select l.type.val

        Dim uniqueFactors = From factor In ftypes Distinct

        For Each f In uniqueFactors

            Dim tabpage As New TabPage
            tabpage.Text = f.ToString

            Dim dgv As New DataGridView
            dgv.Dock = DockStyle.Fill
            dgv.Name = "dgv" & f.ToString

            Dim dgvcol As New DataGridViewColumn
            dgvcol.HeaderText = "Name"
            dgv.Columns.Add(dgvcol)

            tabpage.Controls.Add(dgv)

            TabControl1.TabPages.Add(tabpage)

            PrintIn(f.ToString)
        Next

        For Each item In list
            Dim dgv As DataGridView = ' Here i would like to get by name like ; "dgv" & item.type.val.ToString
        Next

Open in new window


Here i would like to accessing by name;
            Dim dgv As DataGridView = ' Here i would like to get by name like ; "dgv" & item.type.val.ToString

Open in new window

0
Hi All,

Ok I have a Function that needs to run in the background from the Same UI as the rest of the Program. I am using Visual Studio 2017 and VB.net.

I have been able to get most of the Function working in the background using the Backgroundworker control. This is a Very large function and it DOES need to periodically output some data to a TEXTBOX during its operation.

I know that I need to setup DELEGATES to workaround this Cross-Thread problem but I am only partially successful in my endeavors.  With the Delegate that I created I can only write to one TEXTBOX but not another..

So in my research I find that there is a method of turning off  the Checking of this condition.. I see that the option that I must set is 'Control.CheckForIllegalCrossThreadCalls. I understand that this is not recommended  but my  problem is that I Can Not find this Option to set...

Also if I try to use the 'INVOKE' method I cannot find the 'InvokeRequired' method which I believe is the reason  why my DELEGATE is only partially successful.

I would be grateful for help in either finding these options or in getting my delegates to work properly.
Obviously I will provide as much of my code as you wish  to see upon request.

Thanks in advance
Rick
0
Hello,

I've similar topic before and find a solution with help of friends in following topic.

Displayin specific UserControl for selected node in vb.net
https://www.experts-exchange.com/questions/29142992/Displayin-specific-UserControl-for-selected-node-in-vb-net.html

Dim controls = GetType(GUI).Assembly.GetTypes.Where(Function(t) t.BaseType.Equals(GetType(UserControl)))
For Each element in treToolNavigation.Nodes.Cast(Of TreeNode)
    element.Tag = controls.FirstOrDefault(Function(t) t.Name.StartsWith(element.Text))
Next

Open in new window


And this is after node sleect event to show selected user control.

    Private Sub ToolNavigationAfterSelect(sender As Object, e As TreeViewEventArgs) Handles treToolNavigation.AfterSelect

        For Each ctrl As Control In IndexModuleTools.Panel2.Controls.Cast(Of Control).Reverse()
            ctrl.Dispose()
            IndexModuleTools.Panel2.Controls.Remove(ctrl)
        Next
        Dim dynType As Type = CType(e.Node.Tag, Type)
        Dim instance As Control = CType(Activator.CreateInstance(dynType), Control)
        instance.Dock = DockStyle.Fill
        IndexModuleTools.Panel2.Controls.Add(instance)
        instance.Show()
    End Sub

--- NOW --- i'd like to show Windows.Forms of another project which is included my solution but i don't know how it would be possible?

Any helps would be grateful.
0
I'm using below code for CurrentCellDirtyStateChanged but i have to add all of them manually to list as you can see. It's a bit hard because sometimes you may forgot to add event list so is there any way to do that automatically?

    Private Sub CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles _
        dgvBuildExportList3d.CurrentCellDirtyStateChanged, dgvBuildExportListFe.CurrentCellDirtyStateChanged, dgvBuildExportListHp.CurrentCellDirtyStateChanged,
        dgvBuildExportListIfctn.CurrentCellDirtyStateChanged, dgvBuildExportListInfo.CurrentCellDirtyStateChanged, dgvBuildExportListMp.CurrentCellDirtyStateChanged,
        dgvBuildExportListPa.CurrentCellDirtyStateChanged, dgvBuildImportListFe.CurrentCellDirtyStateChanged, dgvBuildImportListHp.CurrentCellDirtyStateChanged, dgvBuildImportListInfo.CurrentCellDirtyStateChanged, dgvBuildImportListMp.CurrentCellDirtyStateChanged,
        dgvBuildImportListPa.CurrentCellDirtyStateChanged
        Dim dgv As DataGridView = DirectCast(sender, DataGridView)
        dgv.CommitEdit(DataGridViewDataErrorContexts.Commit)
    End Sub

Open in new window

0
I'm using COM-interface which belongs to 3rd part program. In this COM-structure there's a function getElements which returns a class IscrElementList and it stores IscrElement items.

IscrElementList has two property count and item. I have chance to access item by item(int index)

In my method i'm getting these IscrElement items like;

Dim objList As IScrElementList = mdl.getElementList(False)
        For i As Integer = 0 To objList.count - 1
            Dim obj As IScrElement = CType(objList.item(i), IScrElement)
            PrintIn(obj.fullName)
        Next

Open in new window


Is it possible to get this items via using Linq ?

Any help would be grateful. Thanks.
0
Hello,

I have a tool like a picture below and it's getting bigger and bigger so it's hard to Debug it and work it. So i decide to seperate it to modules as on picture below but i don't know how is it possible because all modules are using same global variables and i don't how is it possible to link them.

Picture1.png
Any help would be grateful. Thank you.
0
I have tiles that I am loading in a repeater using VB.net.
TileExample.PNG
For each tile, when they hover over the percentage I want to display a tag that is a button.
TileExampleHover.PNG
I want to use Jquery to do this, but I also want to make sure that it's displaying the 'View More' tag that is tied to the corresponding percentage label. Is this possible?

This is my code. I simplified the table so it wouldn't have all the fields. It just has the fields that are concerned with my question.
<table id="TableTraining" class="display scrollTable cards" style="width: 100%; text-align: left !important; font-size: 14px;">
            <thead>
                <tr class="colorFontRTOBlue" style="font-size: 12px;">
                    <th class="">Percentage
                    </th>
                </tr>
            </thead>
            <tbody id="dataContainer" clientidmode="Static" runat="server">
                <asp:Repeater ID="repRepeater" runat="server">
                    <ItemTemplate>
                        <tr id="row" class="<%# Eval("divRowClass").ToString()%>" style="cursor: pointer;">
                            <td class="stylRow5Perc stylTileLabel stylTileActive stylActivePercent">
                                <asp:Label ID="lblActiveStatus" Text='<%# Eval("ActiveStatus").ToString()%>' runat="server"></asp:Label>
                                <asp:Label ID="lblPercentageTile" Text='<%# Eval("Percentage").ToString()%>' 

Open in new window

0
Occasionally a form fails to open in Visual Studio because of a duplicate line of code in the xxx.Designer.vb file.  After I remove the duplicate line of code the form returns to normal.

What is the cause of this?  How do I keep this from happening?

Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.components = New System.ComponentModel.Container()
0
Hi

I am using the following VB.net code in creating an ASP.net chart
        Dim series4 As New Series()
        series4.Name = "Series 4"
        series4.ChartType = SeriesChartType.Line
        series4.Color = Drawing.Color.Green
        series4.BorderWidth = 2
        series4.XValueMember = "Date"
        series4.YValueMembers = "Day Work Rate"
        series4.LegendText = "Day Work Rate"
  ChartData.Series.Add(series4)

Open in new window


I want to flip the axes of the chart. Should I just use

 series4.XValueMember = " series4.XValueMember = "Date"
        series4.YValueMembers = "Day Work Rate"
        series4.YValueMembers = "Date"
        series4.LegendText = "Date"

Open in new window

0
I am try to take a 1 dimensional array of data and transform it to display in X number of columns each with X number of rows for each page into a datatable to easily display as the sample below shows. I am not sure the best way to do this.

Just to test the example I want 3 columns per page, and each column will contain 3 rows with the sample data below there should be 2 pages with 3 columns and a 4 page will have only 1 col and 1 row of data remaining.

samplearray= "{"100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280"}"

Example Output:

[Page #1]

[Column #1]     [Column #2]     [Column #3]
100                     130                    160
110                     140                    170
120                     150                    180

[Page #2]

[Column #1]     [Column #2]     [Column #3]
190                     220                     250                    
200                     230                     260                    
210                     240                     270                    

[Page #3]

[Column #1]     [Column #2]     [Column #3]
280
0
Anybody has a good example Using Exchange Web Service (EWS) to get the emails from and specific folder?


 have a Folder call it Filesemail  and I would like to get the email form that specific folder


im using VB.net


thank you
0
I have a Main TabControl and it has several TabPages and this TabPage's has several tab controls and continues like this. Main TabControl is not directly the main container of datagridviews.

I'd like the list all DataGridViews under this Main Tab control and clear their rows.

How can i do that? Any help would be grateful.
0
I'm using below code to split my filename and get into string array after that i'm writing them  to datagridview. In here if it's index out of bound for example filenameArr(2) is not existing how can i show it simple "-" string value.
            Dim filename As String = Path.GetFileNameWithoutExtension(str)
            Dim filenameArr() As String = filename.Split(New String() {"__"}, StringSplitOptions.None)
            dgv.Rows.Add(obj.name, filenameArr(0), filenameArr(1), filenameArr(2), filenameArr(3), filenameArr(4))

Open in new window

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,