• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 135
  • Last Modified:

the code please

Hi,

Dim sVar As String, iVar As Integer
sVar = “A 1-12-15”

What is the function (or code) which lets iVar = 15  
(I mean the last number after “-“ , this number should be any number from 1 to 999999)

thanx
0
asns
Asked:
asns
1 Solution
 
marconovaroCommented:

Here it is:

Private Sub Form_Load()

Dim sVar As String, iVar As Long

sVar = "A 1-12-356425"

iVar = Val(Right$(sVar, Len(sVar) - InStrRev(sVar, "-", , vbTextCompare)))

End Sub

Please note that you'll need a long variable to store 999999... :)

M
0

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now