Solved

Addin

Posted on 2001-06-26
10
230 Views
Last Modified: 2010-05-02
Hi i want to be able to modify code while a project is running...i was thinking like make the code in a file and then just modify the code in the file but how would i run the code does any one have an idea of like a code processor so i can make addons for my programs...


Thanks BrianG.
0
Comment
Question by:BrianGEFF719
  • 5
  • 4
10 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 6229539
Build a VB interpreter.  The only practical way to change compiled code on the fly is to have the process build a dll that can be dynamically changed while the program runs.  Normally this is dangerous, but I think .NET is attempting to deal with it.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6229746
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6230532
I'm writeing my own code to run through the code and perform preset functions...i have a problem though when trying to parse the code to extrace a bit of code i have trouble...points will be awarded to anyone that can tell me why the heck this code doesnt work!

Public Sub process_names()
varTmp1$ = Form3.Text1
For xp = 1 To Len(varTmp1$)
strt$ = Mid(varTmp1$, xp, 9)
        If strt$ = "[(START)]" Then
            xst = xp
            For qp = xst To Len(varTmp1$)
            so$ = Mid(varTmp1$, qp, 7)
                If so$ = "[(END)]" Then
                    est = qp
                    c$ = Mid(varTmp1$, xst, Len(varTmp1$) - est)
                    MsgBox c$
                    GoTo oj:
                Else
                End If
            Next qp
        Else
        End If
oj:
est = ""
so$ = ""
xst = ""
Next xp
End Sub
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6232175
Well, your code is not the how I would write it but...

1) What is your goal, that it's not working?  Are you trying to display the stuff between the start and end codes?

2) The line Mid(varTmp1$, xst, Len(varTmp1$) - est) is displaying a substring starting at xst.  xst is where it first found [(START)], rather where it ends...
  Change: xst = xp
  To: xst = xp + 9
And est is where it first found [(END)], which is the end point, so...
  Change:  Mid(varTmp1$, xst, Len(varTmp1$) - est)
  To: Mid(varTmp1$, xst, est - xst)

Personally, I'd use the INSTR function to find the desired strings, which will give you the starting position of that string.  This circumvents the loops and makes it easier to extract the text.  This is similar to your code, but using instr rather than the loops:

varTmp1$ = Form3.Text1.text
xp = instr(varTmp1$, "[(START)]")
if xp>0 then
  xst = xp+9
  qp = instr(varTmp1$, "[(END)]")
  if qp>0 then
    c$ = mid$(varTmp1$, xst, qp-xst)
  else
    msgbox "end not found"
  endif
else
  msgbox "start not found"
endif
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 6232185
Anothing thing, being that you're using "goto" and "$", I'm guessing that you learned BASIC long ago, before the advent of object-oriented programming.

I'd suggest picking up a book or taking a class because there's a lot of worthwhile stuff here.  I struggled for about 6 months to get up to speed on VB, and I'd been doing BASIC for over 10 years before that.  then it took me several more years to really understand how the object-oriented stuff works, but now it's a lot easier to code.

(Also, look up "Option Explicit" and "Variable Types".)
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6244274
Thanks for your help...i got it fixed before you responded...and the thing is...there is multiple "{STARTS}" and "{ENDS}" so instr is not an option... :(

And yes I have been using basic for a long time i first started with QBASIC that comes with windows 3.1 and i've been doing it ever since...i'm going to get a book i think...i'm going to give you points anyway just because you took the time to respond...thanks a lot


Brian.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6249541
Thanks.  If I can be of any more assistance, feel free to reply here.
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 13175807
wow, I wrote some horrible code back in the day :(
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 13188326
Welcome back and I suppose to the world of object-oriented programming.

BTW--every year, there's plenty more to learn, so don't put those books down just yet...
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 13188364
LOL, I know I learn more everyday, but just looking back at this code makes me laugh to think I wrote such crappy code!!!

lol
-brian
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

705 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

12 Experts available now in Live!

Get 1:1 Help Now