Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   When using variables things dont work.. (http://www.programmingforums.org/showthread.php?t=10635)

Keiran Jul 5th, 2006 8:38 PM

When using variables things dont work..
 
Been trying to figure out how to make it work for the last few hours, not sure what to search for on google, so i thought i'd ask here, and *hope* for an answer
:

If InStr(dmsg, prefix & "makedir") = 1 Then
Dim MakeDirectory As String
'MsgBox dat(4), vbOKOnly, "Testing.."
MakeDirectory = dat(4)
Call MkDir(MakeDirectory)
End If

The code works fine when MakeDirectory = "C:\Testing"
but if i change it to dat(4) which is part of an array, and in the MsgBox shows fine as "C:\Testing" it wont work..
dmsg, refers to the first word/command given to it on the irc server
and dat(4) refers to the second, like
example:
(+Keiran) .makedir C:\Testing
Hope ive explained it Ok !
Thanks

Kilo Jul 5th, 2006 9:18 PM

Well MkDir("C:\TestingThis") works fine for me... so my next guess it that the 4 element (i forgot how indexing works in vb) of your array dat is something different. Although your msgbox works maybe there is space or and odd character at the end throwing it off?

Does it bomb out...?

Does it produce an error?

Keiran Jul 6th, 2006 6:05 AM

I changed the code to have error checking, and to remove any spaces from the variable to see if that was the problem

:

If InStr(dmsg, prefix & "makedir") = 1 Then
On Error GoTo mkdirerr
Dim Dir2Make As String
Dir2Make = Replace(dat(4), " ", "")
Call MkDir(Dir2Make)
wsCon.SendData SendMessage & "Operation Complete " & vbCrLf
mkdirerr:
wsCon.SendData SendMessage & "Operation Failed - " & Err.Description & vbCrLf
End If


This is the error i get
:

( 11:43:26 ) ( Keiran[away] ) .makedir C:\Testing
( 11:43:28 ) ( Administrator ) Operation Failed - Path not found


linxis Jul 19th, 2006 2:14 PM

put the array declaration up
that may be the error

I havn't used VB in a while but isn't an array like this data[4] or is taht only c


All times are GMT -5. The time now is 8:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC