Solved

Code as a DLL or Control?

Posted on 2009-05-03
3
165 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 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

16 Experts available now in Live!

Get 1:1 Help Now