cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Visual Basic question

davehaigh
11-Garnet

Visual Basic question

So this morning I downloaded visual basic express, and have about an hour of experience with it.

I searched around the web and found out how to use environment variables in the script, but I don't know the proper syntax to extend that path to sub directories. If you know any VB please enlighten me.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim wsh, fs, profile
wsh = createobject("WScript.Shell")
fs = CreateObject("Scripting.FileSystemObject")
profile = wsh.ExpandEnvironmentStrings("%UserProfile%")
ChDir(profile)& "\pro\Creo_2_Home" <---doesn't like this syntax
Shell("C:\ptc\startup_scripts\creo_2_local-no-pdm-start.bat")
End Sub
End Class


If I just do this:
ChDir(profile)
It works and my working directory in Creo is my %USERPROFILE%

But obviously I want it to be %USERPROFILE%\pro\Creo_2_Home

David Haigh
Phone: 925-424-3931
Fax: 925-423-7496
Lawrence Livermore National Lab
7000 East Ave, L-362
Livermore, CA 94550

1 REPLY 1

Answer from Catherine Alarid:
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim wsh, fs, profile
wsh = createobject("WScript.Shell")
fs = CreateObject("Scripting.FileSystemObject")
profile = wsh.ExpandEnvironmentStrings("%UserProfile%" + "\pro\Creo_2_Home")
ChDir(profile)
Shell("C:\ptc\startup_scripts\creo_2_local-no-pdm-start.bat")
End Sub
End Class

This works like I want.

David Haigh
Announcements
Attention: Creo 7.0 Customers
Please consider upgrading
End of Life announcement here.

NEW Creo+ Topics:
PTC Control Center
Creo+ Portal
Real-time Collaboration