|
How would you tackle this one?
|
|
|
|
|
Anonymous wrote:
How would you tackle this one?
How would one tackle what
|
|
|
|
|
With the \ in quotes. \ is used to escape things, so you probably need to do Split('\\') instead of Split('\').
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Oh ok, is that also in VB? I thought that escaping with \ was only in C, C++ and C#.
I never had any problems with it...
|
|
|
|
|
I dunno, but I can't imagine why else someone would use chr(92) or whatever it was.
How do you put a control character in a string in VB then ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well, i think that is the only flaw in VB
Instead of "Blablabla\nSome more bla", you have to do "Blablabla" & vbNewLine & "Some more bla"
Also, \t = vbTab, \" = "" and \x92 = Chr(92)
A lot more typing...
Cheers!
|
|
|
|
|
Absofukinlutely wrote:
Well, i think that is the only flaw in VB
ROTFL - don't get me started.....
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
That's where the wink is for, right?
See ya!
|
|
|
|
|
i cant remember if \ is a control character in VB but certaintly in VB6 i used to use the chr(92) format quite a lot. For one project i needed to build a VBScript string containing SQL and i found using the character ref was pretty much the only way when creating a string with ' " combinations. Dont think its as much of a problem in VB.Net but i havent really tried.
jon
|
|
|
|
|
Split is probably the easiest way to do this, as has been said, but a regular expression could also be used if you wanted to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Not sure exactly what you are after; here are several possibilities:
Where s = "C:\Targets\TestAirplane\TestAirplane_WebDoc\TestAirplane_HDS\01 Fuse"
s.Substring(0, s.IndexOf("Targets\") + 8)
Returns "C:\Targets\"
s.Substring(s.IndexOf("Targets\") + 8, s.Length - s.IndexOf("Targets\") - 8)
Returns "TestAirplane\TestAirplane_WebDoc\TestAirplane_HDS\01 Fuse"
s.Substring(s.IndexOf("Targets\") + 8, s.IndexOf("\"c, s.IndexOf("Targets\") + 8) - s.IndexOf("Targets\") - 8)
Returns "TestAirplane"
|
|
|
|
|
Is there a way to get the selectedvalue (or selectedtext or selecteditem) from a databound combobox into a string variable? I keep getting cast from datarowview to type string not valid.
|
|
|
|
|
Give one of these a try:
ComboBox.SelectedValue.ToString
OR
ComboBox.SelectedItem.ToString
|
|
|
|
|
I had already tried that.
still cast from datarowview to type string not valid
|
|
|
|
|
|
Also, have you tried:
ComboBox.Text
|
|
|
|
|
The error is in result of a query
'field_names is a string
'field_number is the underlying value
commandtext = "Select field_number,field_names From field_info where field_number = " & cbfieldEdit6.SelectedValue.ToString
cbfieldedit6.text works, but I need the underlying value
I think I will have to do it in a round about way...
commandtext = "Select field_number,field_names From field_info where field_names = " & cbfieldEdit6.text
and then use a datareader to get the value I need.
field1 = dr.getvalue(0)
oops... modified query
commandtext = "Select field_number,field_names From field_info where field_names = '" & cbfieldEdit6.text & "'"
|
|
|
|
|
|
I ended up querying the database for the underlying value using the combobox.text for the Where clause (Thankfully it doesn't cause much overhead)
I looked all over, and I am beginning to think that what I was trying to do is impossible by .net design. It is expected that you will be updating the datasource using the (updated) dataset.
.text is the only data that I could get out of a databound combobox.
|
|
|
|
|
Good Day,
I have decided that it is necessary to resize a form (new base size) as well as all of the controls it contains. But although I resize the form and its elements, when I run the program in debug mode (even after building & rebuilding both the project and solution) the changes do not take effect at run-time...only at design time.
Any help is greatly appreciated.
mtognetti
|
|
|
|
|
is it possible to make a program develpoed in vb.net and another one in c++ and make them communicate with each other using socket programming.if possible,how? Thanks
|
|
|
|
|
Of course you can! Over sockets, neither side gives a **** what language the other is written in.
One side needs to be written as a server and the other as a client. Kind of like an FTP server and FTP client.
But, something is telling me that your requirements won't be satified with this method. So, dare I ask... What are you REALLY trying to accomplish using this communication method?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I can list my drives, my folders, my files, I can see everything that my computer has, using vb.net, now, How can I move the selected file (any file) on the filelistbox to a fixed destination?.
Can I select a file from the filelistbox and then click the move(btn_click1) button to move the record to the specific location?. How can I do that? Is it possible?
I'm trying to create a copying and moving program with fixed source and destination, specific for the company I work for. I can list my files, folders everything but i do not know how to move items from a listbox to a specific folder.
|
|
|
|
|
I'm not sure what your FileListBox contains, but I will assume it contains the specified path of the file? If so, you can try the following:
Private Sub btnMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMove.Click, btnCopy.Click<br />
<br />
Dim btnClicked as Button<br />
'assuming selected item is String <br />
'for the full path of an existing file<br />
Dim f as New FileInfo(FileListBox.SelectedItem.ToString)<br />
<br />
btnClicked = CType(sender, Button)<br />
<br />
'Move or Copy according to clicked button<br />
Select Case btnClick.Name<br />
Case "btnMove"<br />
'Move to destination directory - f.Name indicates the original file name<br />
f.MoveTo("destDir\" + f.Name)<br />
'OR<br />
'File.Move(sourceFileName, destFileName)<br />
Case "btnCopy"<br />
f.CopyTo("destDir\" + f.Name)<br />
'OR<br />
'File.Copy(sourceFileName, destFileName)<br />
End Select<br />
End Sub
|
|
|
|
|
Thanks for your help, but i'm getting an error:
< Cannot find the file specified > (but the file has been selected from the filelistbox) so i don't know. this is what I have so far:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'local scope
Dim myDirectories() As System.IO.DirectoryInfo
Dim i As Integer
'create a new directory object pointed at c:
Dim myDirectory As New System.IO.DirectoryInfo(Path:=mypath)
'return the sub directories of c: from the global directory object
myDirectories = myDirectory.GetDirectories()
'loop through the directories and add them to the list box
For i = 0 To UBound(myDirectories) - 1
'add the directory name to the list
ListBoxdirectories().Items.Add(myDirectories(i).Name)
Next
'select the first directory in the list
' note: this will trigger the events that fill the label control
' and the files list box and its label control
ListBoxdirectories().SelectedIndex = 0
End Sub
Private Sub ListBoxdirectories_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBoxdirectories.SelectedIndexChanged
'purpose: synchronize the files list box with the selected directory
' and display the selected directory's information
'local scope
Dim myDirectory As System.IO.DirectoryInfo
Dim dirInfo As String
Dim myFiles() As System.IO.FileInfo
Dim i As Integer
myDirectory = New System.IO.DirectoryInfo(Path:=(mypath & mydirname))
'clear the listbox of its current contents
ListBoxFiles().Items.Clear()
'get a directory info object based on the user's selection
mydirname = ListBoxdirectories().SelectedItem.ToString & "\"
myDirectory = New System.IO.DirectoryInfo(Path:=(mypath & mydirname))
'set the dir info
dirInfo = dirInfo & "Path: " & myDirectory.FullName & vbCrLf
dirInfo = dirInfo & "Attributes: " & myDirectory.Attributes.ToString _
& vbCrLf
Labeldirectoryinfo().Text = dirInfo
'get the files in the directory
myFiles = myDirectory.GetFiles()
'check for files
If UBound(myFiles) >= 0 Then
'loop through the files array and add to the listbox
For i = 0 To UBound(myFiles) - 1
ListBoxFiles().Items.Add(myFiles(i).Name)
Next
'select the file in the list, this will trigger the event to change
' the file info label control listBoxFiles().SelectedIndex = 0
End If
End Sub
Private Sub ListBoxFiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBoxFiles.SelectedIndexChanged
'purpose: change the contents of the file properties label
'local scope
Dim myFile As System.IO.FileInfo
Dim fileInfo As String
'set the file name
myfilename = ListBoxFiles().SelectedItem.ToString
'create a new file object
myFile = New System.IO.FileInfo(fileName:=mypath & mydirname & _
myfilename)
'set the file info to display
fileInfo = fileInfo & "Directory: " & myFile.DirectoryName & vbCrLf
fileInfo = fileInfo & "Created Time: " & myFile.CreationTime & vbCrLf
fileInfo = fileInfo & "Size: " & myFile.Length & vbCrLf
fileInfo = fileInfo & "Last Accessed: " & myFile.LastAccessTime & _
vbCrLf
fileInfo = fileInfo & "Attributes: " & myFile.Attributes.ToString & _
vbCrLf
'set the label to the file's info
Labelfileinfo().Text = fileInfo
End Sub
Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
'purpose: end the application
'close the form
Me.Close()
End Sub
Private Sub btnMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMove.Click
Dim btnClicked As Button
'assuming selected item is String
'for the full path of an existing file
Dim f As New FileInfo(ListBoxFiles.SelectedItem.ToString)
btnClicked = CType(sender, Button)
'Move or Copy according to clicked button
Select Case btnClicked.Name
Case "btnMove"
'Move to destination directory - f.Name indicates the original file name
f.MoveTo("destDir\" + f.Name)
'OR
'File.Move(sourceFileName, destFileName)
Case "btnCopy"
f.CopyTo("destDir\" + f.Name)
'OR
'File.Copy(sourceFileName, destFileName)
End Select
End Sub
|
|
|
|