Solved

Code as a DLL or Control?

Posted on 2009-05-03
3
160 Views
Last Modified: 2013-12-26
Hi Experts,

Now I'm not sure if this is possible, but I'd like to convert the following code into either a control, or a DLL. The code below currently sits in a menuitem procedure which when clicked, takes data stored in a text file and sends it to a pre-defined web page.

What I need is to have the text elements of the code i.e msgbox text, configurble as part of a control with properties to set or as a configurable DLL if there is such a thing? The most important part though is the web request create, Ideally I want it so that I can enter a number in a control poroperty and the code creates the temp variables?

ProgressBar1.Visible = True

        ProgressBar1.Value = 10

        Try

            If File.Exists(strAppDir & "\import.txt") = True Then
 

                Dim fsa As New FileStream(strAppDir & "\import.txt", FileMode.Open, FileAccess.Read)

                'declaring a FileStream to open the file named import.txt with access mode of reading

                Dim da As New StreamReader(fsa)

                da.BaseStream.Seek(0, SeekOrigin.Begin)
 

                Dim tempa As String
 

                'Send the data to the script

                Do While da.Peek() > -1

                    Dim temp As String()

                    tempa = da.ReadLine
 

                    Dim fl As Int16 = 0

                    Dim i2 As Int16 = 0
 

                    temp = tempa.Split(" ")
 

                    Dim req As WebRequest = WebRequest.Create(script & "?1=" & temp(0) & "&2=" & temp(1) & "&3=" & temp(2) & "&4=" & temp(3) & "&5=" & temp(4) & "&6=" & temp(5) & "&7=" & temp(6) & "&8=" & temp(7) & "&9=" & temp(8) & "&10=" & temp(9) & "&11=" & temp(10) & "&12=" & temp(11) & "&13=" & temp(12) & "&14=" & temp(13) & "&15=" & temp(14) & "&16=" & temp(15) & "&17=" & temp(16) & "&18=" & temp(17) & "&19=" & temp(18) & "&20=" & temp(19) & "&21=" & temp(20) & "&22=" & temp(21) & "&23=" & temp(22) & "&24=" & temp(23) & "&25=" & temp(24) & "&26=" & temp(25) & "&27=" & temp(26) & "&28=" & temp(27) & "&29=" & temp(28) & "&30=" & temp(29) & "&31=" & temp(30) & "&32=" & temp(31) & "&33=" & temp(32) & "&34=" & temp(33) & "&35=" & temp(34) & "&36=" & temp(35) & "&37=" & temp(36) & "&38=" & temp(37) & "&39=" & temp(38) & "&40=" & temp(39) & "&41=" & temp(40) & "&42=" & temp(41) & "&43=" & temp(42) & "&44=" & temp(43) & "&45=" & temp(44) & "&46=" & temp(45) & "&47=" & temp(46) & "&48=" & temp(47) & "&49=" & temp(48) & "&50=" & temp(49) & "&51=" & temp(50) & "&52=" & temp(51) & "&53=" & temp(52) & "&54=" & temp(53) & "&55=" & temp(54) & "&56=" & temp(55) & "&57=" & temp(56) & "&58=" & temp(57) & "&59=" & temp(58) & "&60=" & temp(59) & "&61=" & temp(60) & "&62=" & temp(61) & "&63=" & temp(62) & "&64=" & temp(63) & "&65=" & temp(64) & "&66=" & temp(65) & "&67=" & temp(66))

                    Dim resp As WebResponse = req.GetResponse()

                    resp.Close()
 

                Loop

                ProgressBar1.Value = 100

                da.Close()

                File.Delete(strAppDir & "\import.txt")

                ProgressBar1.Value = 0

                ProgressBar1.Visible = False

                MsgBox("Data transmission successful.", MsgBoxStyle.OkOnly, "Project MFD")

            End If
 

        Catch ex As IndexOutOfRangeException

            MsgBox("An unauthorised manual modification of the transmission data has occurred, please contact support for assistance.", MsgBoxStyle.OkOnly, "Project MFD Error")
 

        Catch ex As Exception

            MsgBox("One of the following errors has occurred:" & (Chr(13)) & (Chr(13)) & "1. MDA signal is weak. (Perform soft reset with the stylus, move to a better area, try again)" & (Chr(13)) & (Chr(13)) & "2. MDA transmitter is switched off. (Call support)", MsgBoxStyle.OkOnly, "Project MFD Transmission Error")

            ProgressBar1.Value = 0

            ProgressBar1.Visible = False
 

        End Try

Open in new window

0
Comment
Question by:Zoooink
  • 2
3 Comments
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24292473
If you want GUI then control if not DLL
0
 
LVL 3

Author Comment

by:Zoooink
ID: 24295570
No GUI is required, but I need to be able to set properties, is it just a case of copying this code and creating a DLL? I have never done one...
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 500 total points
ID: 24300773
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now