Solved

searching for a quote in VB

Posted on 2010-11-30
7
274 Views
Last Modified: 2012-05-10
I have a text like the following

ShowMessage("Hello World", "abc")

I try to extract the 'Hello World' text message out in VBA if  I see it is a function ShowMessage.  Of course that can be a space before and after '('.

I have right up a function to examine the function name, then open bracket, and then try to search for the double quote.  What I notice that the Mid(string, 1, 1) function will return me 'H' whether my string is "Hello" or Hello.  
Is there any way I can search for double quote.
Or some other mean to extract the text message.

Thanks.
0
Comment
Question by:tommym121
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34241597
I hope I have understood your query correctly. If not, then please ignore this post and let me know what exactly do you want...

Sub Sample()
    Dim strString As String
    
    strString = """" & "hello" & """"
    
    MsgBox strString
    MsgBox Mid(strString, 1, 1)
End Sub

Open in new window

0
 

Author Comment

by:tommym121
ID: 34241641
The problem, I have import this file with columns of this types of data. What do I do in that situation?
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34241648
something like this?

Thomas
sub get quotes



Dim str As String

str = selection

str = Left(Mid(str, 1 + InStr(str, "(""")), InStr(Mid(str, 1 + InStr(str, "(""")), ""","))

debug.print str



end sub

Open in new window

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 30

Assisted Solution

by:SiddharthRout
SiddharthRout earned 250 total points
ID: 34241669
May I see a sample file?
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34241682
then for your whole selection:
Sub dgasdg()

Dim str As String, cl As range





For Each cl In selection.Cells



    If InStr(cl, "ShowMessage") > 0 Then _

        cl = Left(Mid(cl, 1 + InStr(cl, "(""")), InStr(Mid(cl, 1 + InStr(cl, "(""")), ""","))



Next



End Sub

Open in new window

0
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 250 total points
ID: 34241687
Use InStr to find the position of the first doublequote character in a string. The doublequote character's ASCII code is 39.


Dim intPos as Integer
Dim strSearch as String

intPos = InStr(strSearch, chr(39))

If intPos = 0 Then
  Debug.Print "No double-quotes found in string"
Else
  Debug.Print "File double-quote found at position " & intPos & "."
End If

HTH,
pT72
0
 

Author Closing Comment

by:tommym121
ID: 34247696
Thanks.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

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 …
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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

757 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

20 Experts available now in Live!

Get 1:1 Help Now