Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all 26485 articles
Browse latest View live

VS 2015 How to get folder as const string?

$
0
0
Hi everyone.

How to get folder as const string? I tried every way but I can't.

Code:

    Private Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" ( _
                        ByVal hwndOwner As Long, _
                        ByVal lpszPath As String, _
                        ByVal nFolder As Long, _
                        ByVal fCreate As Long) As Long
    Private Const CSIDL_APPDATA As Long = &H1A
    Public Enum FolderConstants
        AppData = CSIDL_APPDATA
    End Enum
    Public Function GetSpecialFolder(folder As FolderConstants)
        Dim tmp$
        tmp$ = Space(260)
        SHGetSpecialFolderPath(0&, tmp$, folder, 0)
        GetSpecialFolder = Trim(tmp$)
    End Function

Code:

Dim UserAppData = GetSpecialFolder(FolderConstants.AppData) & "\GetMyDll.dll"

Code:

    Const ConstStr = UserAppData & vbCr

<DllImport(ConstStr)>
    Private Shared Function GetMyFunc(ByVal GetValue As String) As String  'C++ .dll
    End Function

Error: Constant expression is required.

VS 2015 Read text file lines between brackets

$
0
0
Hi,

I need to read all lines from a text file between header 1 and header 2 as text.
How do I do this?

Example

[Head 1]
Line 1
Line 2
Line 3

[Head 2]
Line 4
Line 5
Etc.

Thanks in advance

VS 2010 [RESOLVED] TrackBar Scale Image and Moving Picture with Mouse-Better explanation in description

$
0
0
If anyone have time to help me is welcome.
First:
I have 2 Forms
1. Form1 will contain PictureBox and OpenFileDialog.
PictureBox Size = 200;200
When i click on PictureBox i will execute OpenFileDialog and choose one photo, When i will click Open i will Show Form2 and selected photo will be inserted on Form2.PictureBox
2. Form2 will contain PictureBox, Button, TrackBar
It should look like this:
Name:  first.jpg
Views: 123
Size:  16.4 KB
Name:  second.jpg
Views: 110
Size:  13.3 KB
Button is not Important.
Now i need help about TrackBar - by increasing or decreasing, image should scale greater or less
also i need help to move that Image left, right or up and down with mouse.
It's similar like adding photo on Facebook
Attached Images
  

Save Path and reload into a picturebox each time app loads.

$
0
0
I think I have the idea, just need some extra oopf to get it done.

I want to load it through settings, the input is a open file dialog, you select the image, once selected the file path is inserted into a textbox, then when the user presses the save button, it is saved to a setting. Each time the window with the picture box is loaded, that picture, unless changed is loaded. The file path of the picture being in the saved setting.

So - How do I "properly" go at this? I got the idea, and I *think* I partially understand how to do it, just need a little more guidance and even a code example to get the path, and save it, I think I have the loading part. (Nothing has been written yet, just been thinking of this)

Thanks!

VS 2017 First line of Default.aspx Parser Error

$
0
0
How do I change the first line.

Site.Master exists with no errors.

Default.aspx also has no errors and _Default works.

It is just the first line. At first there is no errors then when you run it it gives a Parser Error up to Site.Master.

Code:

<%@ Page Title="JSON Edit To JSON and XML" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="JSONeditJSONandXML._Default" %>

Divide whole program into two separate sub (Main() and Private sub)

$
0
0
Hi All, when running below whole program, it works fine. However, I have tried to divide the whole code into two separate modules (Main and Private sub) in VB .NET but unsuccessful.

'//------------------------------
Option Explicit On

Module Module1
Sub Main()

Dim CATIA As INFITF.Application
CATIA = GetObject("", "CATIA.Application")

'// Enter file path and file name to open a CATIA part document
Dim filePath As String
filePath = InputBox("Please enter full file path and CATIAPart file name to continue: ")

CATIA.Documents.Open(filePath) '// Open file but it is not shown on the screen yet
CATIA.Visible = True '// Display part graphic on the screen
CATIA.DisplayFileAlerts = True

MsgBox("A CATIAPart file is just opened.")

'// I try to make below code lines in a separate "Private Sub" so that the Main() sub will call the "Private sub" but somehow my hard try
'// has not been worked. I believe I miss something but do not know what it is. Object or property of CATIA software?

'// Access viewer in current window
Dim oViewer3D As INFITF.Viewer3D
oViewer3D = CATIA.ActiveWindow.ActiveViewer


MsgBox("END")

End Sub

End Module

'//-------------------------------

Any help is really appreciated.

VS 2017 [RESOLVED] DGV - Detect which Cell or Row is Highlighted - Not Selected

$
0
0
This one has me stumped. Searched all over cannot find what I need.How do I explain this?

I have a DGV. When a row or cell is highlighted several fixed cell values, in the row, are displayed on the form (one cell value returns a picture file location), using Text Boxes. I have it working with the .CellClick event. But if a user then navigates using the mouse keys, different cells or rows are highlighted (not necessarily selected). The textboxes are not updated in this case.

Code:

Private Sub DgvMessierData_SelectionChanged(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles dgvMessierData.CellClick

        Dim strDGVImageName As String = ""

        'Get File Name from DGV
        Try
            If e.RowIndex >= 0 Then
                Dim row As DataGridViewRow
                row = Me.dgvMessierData.Rows(e.RowIndex)
                strDGVImageName = row.Cells(10).Value.ToString

                TextBoxMessierNameHeader.Text = row.Cells(3).Value.ToString
                If TextBoxMessierNameHeader.Text = "" Then
                    TextBoxMessierNameHeader.Text = "- No Common Name -"
                End If

                TextBoxMessierNGCHeader.Text = "NGC #: " & row.Cells(1).Value.ToString
                TextBoxMessierTypeHeader.Text = "Type: " & row.Cells(2).Value.ToString
                TextBoxMessierMagHeader.Text = "Magnitude: " & row.Cells(5).Value.ToString
                TextBoxMessierRAHeader.Text = "RA: " & row.Cells(6).Value.ToString
                TextBoxMessierDecHeader.Text = "Dec: " & row.Cells(7).Value.ToString

            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            ' Nothing
        End Try


        'Display Image
        Dim pathFilePath As String = xmlApplicationDataFolder & "\UserData\ImageFiles\MessierObjects"
        Dim pathImagePath As String = pathFilePath & "\" & strDGVImageName

        If Not (PictureBoxMessier.Image Is Nothing) Then
            PictureBoxMessier.Image.Dispose()
            PictureBoxMessier.Image = Nothing
        End If

        Try

            PictureBoxMessier.Image = Image.FromFile(pathImagePath)

        Catch ex As Exception
            pathImagePath = pathFilePath & "\" & "No-image-available.jpg"
            PictureBoxMessier.Image = Image.FromFile(pathImagePath)
        Finally
            ' Nothing
        End Try

    End Sub

How do I detect which Cell, or Row, is highlighted and the update the Text Boxes.

[RESOLVED] Create Form programmatically inside Sub. What prevents it being Garbage Collected ?

$
0
0
I was always under the impression that .net garbage collection would collect un-referenced objects.

For years I've been adding forms programmatically to my projects with code something like this.

Code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim frmNew As New Form
        frmNew.Visible = True

        ' Add some controls etc. to the from

End Sub

and that's always worked. But now I'm curious. As soon as that Sub ClickEvent exits the form, frmNew that I just created is no longer referenced. So what stops it being garbage collected?

I suppose the question came about because in XCode/Swift a form, created inside a function, does go out of scope as soon as the function exits and is immediately destroyed. In Swift it's necessary to declare frmNew outside of any function

So. In .Net, what prevents a form, created inside a sub or function, being Garbage collected once that sub/function exits?

I feel pretty silly asking the question but I'm just just curious.
:rolleyes:

VS 2017 Keep getting "[object Object]" in my alert error code status from my ajax.

$
0
0
I keep getting "[object Object]" in my alert error code status from my ajax. I believe I am returning an invalid json code from my webmethod function:

Code:

<System.Web.Services.WebMethod> Public Shared Function GetDate(ByVal mo As Integer, ByVal dy As Integer, ByVal yr As Integer)
Code:

    json1 = "[{" & """id""" & ":""" & dataa(i, 1) & """," & """datetime""" & ":""" & dataa(i, 2) & """," & """col1""" & ":""" & dataa(i, 3) & """," & """col2""" & ":""" & dataa(i, 4) & """," & """col3""" & ":""" & dataa(i, 5) & """}]"
      Dim serializer = New System.Web.Script.Serialization.JavaScriptSerializer()
      GetDate = serializer.Serialize(json1)

Overwriting ASCII with a Shorter one (ASCII string)

$
0
0
Hi guys, i have a problem ..

I wanna know how I can overwrite ASCII in a file using shorter ones(from a textbox), in my case the offset is &H26 and the maximum number of letters in the string is &H44. the first thing i want to do is to write the textbox's text in &H26 and replace the rest till &H6A (&H44 is the length) with "00" bytes,the exact number of "00" bytes is (&H44 - Textbox1.textlength)
I tried making a code to write it byte by byte but that will take longer.. so if anyone can help i'll gladly appreciate it.

And sorry again if i'm bad at explaining.

List count in jCount

$
0
0
I want a List<jPlace> count in jCount:

Code:

Public Class jCount
    Public Property count() As jPlace()
        Get
            Return m_count
        End Get
        Set
            m_count = Value
        End Set
    End Property
    Private m_count As jPlace()
End Class
Public Class jPlace
    Public Property id() As Integer
        Get
            Return m_id
        End Get
        Set(value As Integer)
            m_id = value
        End Set
    End Property
    Private m_id As Integer
    Public Property datetime() As String
        Get
            Return m_datetime
        End Get
        Set(value As String)
            m_datetime = value
        End Set
    End Property
    Private m_datetime As String
    Public Property col1() As Integer
        Get
            Return m_col1
        End Get
        Set(value As Integer)
            m_col1 = value
        End Set
    End Property
    Private m_col1 As Integer
    Public Property col2() As Integer
        Get
            Return m_col2
        End Get
        Set(value As Integer)
            m_col2 = value
        End Set
    End Property
    Private m_col2 As Integer
    Public Property col3() As Integer
        Get
            Return m_col3
        End Get
        Set(value As Integer)
            m_col3 = value
        End Set
    End Property
    Private m_col3 As Integer
End Class

VS 2017 Moving Dynamic controls to a seperate file

$
0
0
I have a custom control set up like this

Code:

Public Class ctrlAddSitesMenu

    'Declares Buttons for Opening Websites
    Dim OpenTraker As New Button
    Dim OpenDynamics As New Button
    Dim OpenInetPortal As New Button
    Dim OpenFrontPortal As New Button
    Dim OpenLoopcare As New Button
    Dim OpenViryNet As New Button
    Dim OpenSmpl As New Button
    Dim OpenFosWiki As New Button
    Dim OpenLola As New Button

    'Declare Button Constant Varibles
    Dim LocX As Integer = 0
    Dim LocY As Integer = 20
    Dim Row As Integer = 25
    Dim H As Integer = 25
    Dim W As Integer = 115

    Public Sub LoadButtons()

        'Declares attributes for Invidual buttons
        'Declares Button names
        OpenTraker.Name = "btnOpenTracker"
        OpenDynamics.Name = "btnOpenDynamics"
        OpenInetPortal.Name = "btnInetPortal"
        OpenFrontPortal.Name = "btnFrontPortal"
        OpenLoopcare.Name = "btnOpenLoopcare"
        OpenViryNet.Name = "btnOpenVirynet"
        OpenSmpl.Name = "btnOpenSimple"
        OpenFosWiki.Name = "btnOpenFosWiki"
        OpenLola.Name = "btnOpenLola"

        'Declares Button text
        OpenTraker.Text = "Tracker"
        OpenDynamics.Text = "Dynamics"
        OpenInetPortal.Text = "Internet Portal"
        OpenFrontPortal.Text = "Frontier Portal"
        OpenLoopcare.Text = "Loopcare"
        OpenViryNet.Text = "Virynet"
        OpenSmpl.Text = "SIMPL"
        OpenFosWiki.Text = "FosWiki"
        OpenLola.Text = "Lola"

        'Declares Button Size
        OpenTraker.Size = New Size(W, H)
        OpenDynamics.Size = New Size(W, H)
        OpenInetPortal.Size = New Size(W, H)
        OpenFrontPortal.Size = New Size(W, H)
        OpenLoopcare.Size = New Size(W, H)
        OpenViryNet.Size = New Size(W, H)
        OpenSmpl.Size = New Size(W, H)
        OpenFosWiki.Size = New Size(W, H)
        OpenLola.Size = New Size(W, H)

        ' Declares Button Location
        OpenTraker.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenDynamics.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenInetPortal.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenFrontPortal.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenLoopcare.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenViryNet.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenSmpl.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenFosWiki.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row
        OpenLola.Location = New System.Drawing.Point(LocX, LocY)
        LocY += Row


        'Adds Buttons to Menu
        Me.Controls.Add(OpenTraker)
        Me.Controls.Add(OpenDynamics)
        Me.Controls.Add(OpenInetPortal)
        Me.Controls.Add(OpenFrontPortal)
        Me.Controls.Add(OpenLoopcare)
        Me.Controls.Add(OpenViryNet)
        Me.Controls.Add(OpenSmpl)
        Me.Controls.Add(OpenFosWiki)
        Me.Controls.Add(OpenLola)


        'Adds Button Click Handlers
        AddHandler OpenTraker.Click, AddressOf OpenTrackerClick
        AddHandler OpenDynamics.Click, AddressOf OpenDynamicsClick
        AddHandler OpenInetPortal.Click, AddressOf OpenInetPortalClick
        AddHandler OpenFrontPortal.Click, AddressOf OpenFrontPortalClick
        AddHandler OpenLoopcare.Click, AddressOf OpenLoopcareClick
        AddHandler OpenViryNet.Click, AddressOf OpenViryNetClick
        AddHandler OpenSmpl.Click, AddressOf OpenSmplClick
        AddHandler OpenFosWiki.Click, AddressOf OpenFosWikiClick
        AddHandler OpenLola.Click, AddressOf OpenLolaClick

    End Sub
    Private Sub addSitesMenu_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try

        Catch ex As Exception
        End Try
    End Sub

    Private Sub OpenTrackerClick(ByVal sender As Object, ByVal e As EventArgs)
        MessageBox.Show("OpenTracker Button Clicked")
    End Sub
End Class

IN order to clean thing up a bit, I want to move The "LoadButtons" Class to a different file, I assume it would be a class file.

Two things happen I get an error in the Addhandler saying the Open*****Click ins not declared. I also cant seem to figure out how to properly call it.

I have tried

Code:

Try
            LoadButtons()
        Catch ex As Exception
        End Try

and

Code:

Try
            classname.LoadButtons()
        Catch ex As Exception
        End Try

I have also tried

Code:

Imports Classname
None of which is working. I do know the Addcontrols has to go on the main form. As for the rest, I am so lost

Is there a "global" setting for setting up font acroos your project?

$
0
0
I am using VB Studio 2017. Is there a "global" setting that you can use to set the same text font for all your pages within a windows app. project?

VS 2010 RichTextBox Issue with Table formatting

$
0
0
Hi,

Does anyone have a fix for the issue with RichTextBox and Tables

I.e.

Table looks like this in .rtf file

Name:  Capture1.jpg
Views: 16
Size:  10.6 KB

But looks like this when load in RTF box

Name:  Capture2.jpg
Views: 13
Size:  6.8 KB

I am using the normal method to load the file

Code:

RichTextBox1.LoadFile("c:\Test\Example.rtf")
Thanks
Attached Images
  

Converting jpeg images to pdf with VB .NET??

$
0
0
Hi All,

Is there a way to write/convert jpg images directly to pdf file format and combined those individual converted pdf's to a single pdf file in sequential page # in VB .NET?

Thank you All in advance.

textchanged event with input of multiple lengths

$
0
0
Hello Everyone.

I'm hoping you can help. I'm scanning barcodes into a textbox, and the resulting barcode data is at MINIMUM 33 characters long. Some barcodes produce data which is greater than 33 characters.

The goal is to automatically break down the resulting string into their corresponding text boxes (based on the data found within the barcode string). I have this part working fine for barcodes that produce a data string of 33 characters.

The first 26 characters are always consistent, always a fixed length - the remaining characters represent a serial number, and this can change.

What I cannot figure out is how to handle barcodes that produce variable length data. Ideally, textbox4 would contain this serial number data, and would vary in length based on the remaining length of data in the various barcodes.

Right now my event handler looks like this:

Code:

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
      'Receives scanned barcode data into textbox1, then  breaks up the string into the other textboxes
      If TextBox1.Text.Length >= 33 Then
            scan = TextBox1.Text
            TextBox2.Text = scan.Substring(8, 5)
            TextBox3.Text = scan.Substring(15, 10)
            TextBox4.Text = scan.Substring(26, 7)
            TextBox1.Text = ""
            TextBox1.Focus()
            If Not TextBox2.Text = "" Then
                Button1.Enabled = True
            End If
        End If
    End Sub

This works great for fixed-length barcodes, but obviously fails when the length varies.

I revised the code to reflect a greater barcode length, as follows:

Code:

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
      'Receives scanned barcode data into textbox1, then  breaks up the string into the other textboxes
      If TextBox1.Text.Length = 40 Then
            scan = TextBox1.Text
            TextBox2.Text = scan.Substring(8, 5)
            TextBox3.Text = scan.Substring(15, 10)
            dim i as integer
            for i=26 to scan.length -1
                  textbox4.text = textbox4.text & scan.substring(i,1)
            next i
            TextBox1.Text = ""
            TextBox1.Focus()
            If Not TextBox2.Text = "" Then
                Button1.Enabled = True
            End If
        End If
    End Sub

Again, this worked fine, and added the characters to textbox4 in a different manner, but this still reflects a barcode of a hardcoded/fixed length (40 in this case).

I have experimented with various logical operator combinations for the if statement, but the value of "33" is my crux. When the character count hits a MINIMUM of 33 I need it to automatically recognize that it needs to start parsing the string..... but I need it to continue reading the input in case there are more characters. Unfortunately there are no "end of line" designators on the character string, no carriage returns, etc. In this case I just can't figure out how to keep reading until there is no more to read.

Can someone help me with this? I've been staring at it too long.

THANK YOU IN ADVANCE!!

VS 2010 [RESOLVED] One question about Insert Parametirzed query - Access

$
0
0
vb.net Code:
  1. con.Open()
  2.                 Dim insert_user As OleDbCommand = New OleDbCommand("INSERT INTO Users ([Username], [Password]) VALUES (@Username,@Password)", con)
  3.                 insert_user.Parameters.AddWithValue("@Country", txtUsername.Text)
  4.                 insert_user.Parameters.AddWithValue("@Language", txtPassword.Text)
  5.                 insert_user.ExecuteNonQuery()
  6.                 insert_user.Dispose()
  7.                 con.Close()
My question is why everytime is insert working without problem no matter how i will write this one:
Code:

insert_user.Parameters.AddWithValue("@Country", txtUsername.Text)
Even if has been written differently than this one:
Code:

  Dim insert_user As OleDbCommand = New OleDbCommand("INSERT INTO Users ([Username], [Password]) VALUES (@Username,@Password)", con)
it's work whyy??

It's work in both cases
vb.net Code:
  1. con.Open()
  2.                 Dim insert_user As OleDbCommand = New OleDbCommand("INSERT INTO Users ([Username], [Password]) VALUES (@Username,@Password)", con)
  3.                 insert_user.Parameters.AddWithValue("@Username", txtUsername.Text)
  4.                 insert_user.Parameters.AddWithValue("@Password", txtPassword.Text)
  5.                 insert_user.ExecuteNonQuery()
  6.                 insert_user.Dispose()
  7.                 con.Close()

vb.net Code:
  1. con.Open()
  2.                 Dim insert_user As OleDbCommand = New OleDbCommand("INSERT INTO Users ([Username], [Password]) VALUES (@Username,@Password)", con)
  3.                 insert_user.Parameters.AddWithValue("@Country", txtUsername.Text)
  4.                 insert_user.Parameters.AddWithValue("@Language", txtPassword.Text)
  5.                 insert_user.ExecuteNonQuery()
  6.                 insert_user.Dispose()
  7.                 con.Close()

Citrix error deserializing the object

$
0
0
We started getting this error trying to save large text files to the database:

“The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:LoadResult. The InnerException message was 'There was an error deserializing the object of type TeamDTO.Response`1[[TeamDTO.DataObject.Note, TeamDTO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.'. Please see InnerException for more details.”

Researching the error we found suggestions to change the MaxStringContentLength parameter and we set it to 2048000 and that fixed it on the desk top applications. However on Citrix it is producing the same error message as before. I think that Citrix is not recognizing the parameter change for some reason.

The is a .Net WCF application. Has anyone happened to have dealt with this?

Here is the config we changed:
Attached Images
 

Printing to a PDF Printer from WebBrowser Control

$
0
0
Hi,

I have a WebBrowser Control with some HTML in it and I'd like to print this as a PDF (I've tried iTextSharp and other PDF DLL's but they all mess up when showing tables and SVG graphics.

I'd like to automatically print to Microsoft PDF Printer without user interaction but currently that's the part I can't do. I can get all the way to showing the print dialog where you have to fill in a filename. I'd like to automate this part as well but currebtly I can't find a way to do this.

None of the below have any parameters to do anything like I need.
WebBrowser.ShowPrintDialog()
WebBrowser.ShowPrintPreviewDialog()
WebBrowser.Print()

Is there a way using SHDocVw.dll or anything else to Print to a printer but also populating the file location/name so that no user interaction is required?

Cheers

Chris

Visual Basic 2012 Array Problem using only 1 button for multiple events

$
0
0
I have a project and this is my code but I can't seem to get the Sort or FindReplace events to work. What am I doing wrong??
Code:

Public Class MainForm

    Const Max As Integer = 4
    Private Nums(Max) As Integer

    Private Sub GetNumbers()

        Dim X As Integer

        For X = 0 To Max
            Nums(X) = InputBox("Enter Integer")
            lblArray.Text = lblArray.Text & Nums(X).ToString & "  "
        Next X

    End Sub

    Private Sub Add(ByRef Sum As Integer)

        Dim X As Integer

        For X = 0 To Max
            Sum = Sum + Nums(X)
        Next X

    End Sub

    Private Sub Average(ByRef Ave As Double)

        Dim Total As Integer

        Call Add(Total)
        Ave = Total / (Max + 1)

    End Sub

    Private Sub Highest(ByRef HighIndex As Integer)

        Dim X As Integer

        HighIndex = 0

        For X = 1 To Max
            If Nums(HighIndex) < Nums(X) Then
                HighIndex = X
            End If
        Next X

    End Sub

    Private Sub Lowest(ByRef LowIndex As Integer)

        Dim X As Integer

        LowIndex = 0

        For X = 1 To Max
            If Nums(LowIndex) > Nums(X) Then
                LowIndex = X
            End If
        Next X

    End Sub

    Private Sub Sort(ByRef SortNums As Integer)

        Dim X As Integer
        For X = 0 To (Max)
            Call Lowest(X)
            Nums(X) = SortNums
            lblResult.Text = SortNums.ToString
        Next X

    End Sub

    Private Sub FindReplace(ByRef Switch As Integer)

        Dim X, Num As Integer

        Integer.TryParse(InputBox("Enter Integer"), Num)

        X = 0

        Do
            If (Nums(X) = Num) Then
                Integer.TryParse(InputBox("Replace With:"), Switch)
                Nums(X) = Switch
            Else
                X = (X + 1)
            End If
        Loop Until Nums(X) = Num Or X = (Max)

    End Sub

    Private Sub btnExecute_Click(sender As Object, e As EventArgs) Handles btnExecute.Click

        Dim Total, High, Low, SortNums, Switch As Integer
        Dim Avg As Double
        Dim Op As String

        Op = InputBox("Enter the Operation")

        Select Case Op
            Case "G"
                Call GetNumbers()
            Case "Add"
                Call Add(Total)
                lblResult.Text = "The sum is: " & Total.ToString
            Case "Av"
                Call Average(Avg)
                lblResult.Text = "The average is: " & Avg.ToString
            Case "H"
                Call Highest(High)
                lblResult.Text = "The index of the highest integer is: " & High.ToString
            Case "L"
                Call Lowest(Low)
                lblResult.Text = "The index of the lowest integer is: " & Low.ToString
            Case "S"
                Call Sort(SortNums)
                lblResult.Text = lblResult.Text & "  " & SortNums.ToString
            Case "FR"
                Call FindReplace(Switch)
                lblResult.Text = Switch.ToString

        End Select

    End Sub
End Class

Viewing all 26485 articles
Browse latest View live




Latest Images