Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get string from textfile, then compare it to another string

Posted on 2001-08-10
1
Medium Priority
?
171 Views
Last Modified: 2010-05-18
Hi all!

I have a strange problem. Here's the code.
Private Sub cmdTest_Click()
Open "c:\thomas" For Input As #1 ' file opened for reading
   
    'While Not EOF(1)
        Line Input #1, instring1
        Line Input #1, instring2
        Line Input #1, instring3
        Line Input #1, instring4
        Line Input #1, instring5
    'Wend
Close #1
'MsgBox instring1 & vbCrLf & instring2 & vbCrLf & instring3 & vbCrLf & instring4 & vbCrLf & instring5
scriptlang.RunCommand instring1, instring2, instring3, instring4, instring
End Sub


When I run the sub Scriptlang.RunCommand (here's the code):

Public Sub RunCommand(Command2Run, Syntaxx1, Syntaxx2, Syntaxx3, Syntaxx4)        'Runs the command u ask for
    If Command2Run = "RegDelete" Then RegDelete Syntaxx1, Syntaxx2
    If Command2Run = "RegSetKey" Then RegSetKey Syntaxx1, Syntaxx2, Syntaxx3, Syntaxx4
    If Command2Run = "FileDelete" Then FileDelete Syntaxx1, Syntaxx2
    If Command2Run = "SendMSG" Then SendMSG Syntaxx1
End Sub

It does not evaluate the string Command2Run to be the same as the one on the other side of the = sign.

When I try to use RegSetKey, the value of instring1 is "RegSetKey", and the value of Command2Run is also "RegSetKey". BUT when it compares the string Command2Run with "RegSetKey" it doesn't think it's the same???!

Please help =)

/Thomas
0
Comment
Question by:thomas77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
Otana earned 400 total points
ID: 6372537
Try this:

If Ucase(Trim(Command2Run)) = Ucase(Trim("RegSetKey")) Then RegSetKey Syntaxx1, Syntaxx2, Syntaxx3, Syntaxx4
   
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses

670 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