How to get the 3rd character in a string

Well the title says it all

Let's say i have the string: "abcdefg"
i want to get the 3rd character (ie: "c") what is the function to do so?

This shouln't be too difficult to do
i know in excel the STXT function does it

TIAFYT (thanks in advance for your time)

Luthar
lutharAsked:
Who is Participating?
 
schworakConnect With a Mentor Commented:
Use the MID function

MID(String,Start,Len)



MID("abcdefg",3,1) returns "c"
0
 
lutharAuthor Commented:
Edited text of question.
0
 
lutharAuthor Commented:
Good comment but here's my code:
Option explicit
Dim Nbr_de_coup as integer

Private Sub Form_load()
Genere_La_Solution (Nbr_de_coup)
End sub
----------------------------------
Public Function Genere_La_Solution(ByVal Nbr_de_Case)

Dim x As Integer
Dim Nbr_Genere As String


    For x = 0 To Nbr_de_Case
        Let Nbr_Genere = Int(Rnd() * 5)
        Solution = Solution & Nbr_Genere
    Next x
   
End Function
------------------------------------
Public Sub Label1_Click(Index As Integer)
Dim i As Integer

Nbr_de_coup = Nbr_de_coup + 1

For i = 1 To Len(Solution)
Reponse = Mid(Solution, i, 1)
If Reponse <> Index Then
    MsgBox "Vous avez pousser une mauvaise touche!", vbOKOnly, "Que c'est dommage!"
    Exit Sub
End If
Next i
-----------------------------------

I get an error at the If Response <>...

Any suggestion?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mark2150Commented:
RESPONSE is a STRING, INDEX is an INTEGER. You can't compare an Integer to a String and get meaningful results...

M
0
 
Erick37Commented:
Is this what you are trying to do?
'...
i = InStr(1, solution, Format(Index))
If i <> Index Then
    MsgBox "Vous avez pousser une mauvaise touche!", vbOKOnly, "Que c'est dommage!"
    Exit Sub
End If
'...
0
 
lutharAuthor Commented:
Sounds more like it but the only problem is that I need the result to be different than 0 or 1 cause i have 5 label in the control array...
I'm gonna put more points cause i think it's worth more :D
0
 
matthewmayerCommented:
To convert a integer to a string use STR$(num). To convert from a string to a number use VAL("string").
0
All Courses

From novice to tech pro — start learning today.