|
Hello,
I found this vb transcripten of the codeproject article mentioned below.
However sometimes I would like to see the whole picture in the ImageViewer.
For this I would have to set the autoscroll to false and the sizemode property of
the embedded imagebox to "stretch".
Do I have to create another property in ImageViewer to change the sizemode to
Normal, StretchImage, AutoSize, CenterImage, Zoom
I am afraid this is beyond my level. Could someone help?
Thank you.
Michael
Public Class ImageViewer
Inherits Panel
'based on http://www.codeproject.com/KB/linq/ScrollablePicturebox.aspx
Dim innerPicture As New PictureBox()
Dim mPictureFile As String = String.Empty
Dim mAutoScroll As Boolean = True
Sub New()
' add the inner picture
innerPicture.Top = 0
innerPicture.Left = 0
innerPicture.SizeMode = PictureBoxSizeMode.Normal
Controls.Add(innerPicture)
End Sub
Public Property PictureFile() As String
Get
Return mPictureFile
End Get
Set(value As String)
mPictureFile = value
If (String.IsNullOrEmpty(mPictureFile) = False) Then
' set the image to the image file
innerPicture.Image = Image.FromFile(mPictureFile)
' resize the image to match the image file
innerPicture.Size = innerPicture.Image.Size
Else
innerPicture.Image = Nothing
End If
End Set
End Property
Public Overrides Property AutoScroll As Boolean
Get
Return mAutoScroll
End Get
Set(value As Boolean)
mAutoScroll = value
End Set
End Property
End Class
|
|
|
|
|
Dear All,
I'm trying to figure out the way to overwrite the existing content of the text file after found the specific word. The example content of text file as below. I'm looking the example in VB.Net to overwrite the words after the "No = " and "ID = ".
Name = MyName
No = 12345678
ID = 2000S1-DD7-8TA
Home = SD-PS-D1
Thanks.
|
|
|
|
|
You load the text file into memory, like an array of strings. Make your replacements with String.Replace(), or whatever is appropriate for your situation, then write the entire file back out to disk.
|
|
|
|
|
As Dave described, load the file into an array of lines.
Replace won't work in this case, you need to chop up the line into
Text before the characters to be replaced
text to be replaced
text after the characters to be replaced
Repeat for the ID =
Then you need to concatenate the bits together with the replacement text. This is not difficult just fiddly and will take some time to get right.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi RAH,
Thanks for the guidance, however, I still unable make the code work as below. Appreciate if you could show the example.
MyProfile_File = "C\MyProfile\MyProfile.txt"
Dim MyProfile_StreamReader As New StreamReader(MyProfile_File)
Dim MyProfile_Content As String
MyProfile_Content = MyProfile_StreamReader.ReadToEnd
MyProfile_StreamReader.Close()
Dim MyProfile_StreamWriter As New StreamWriter(MyProfile_File, True)
Dim a As String()
a = Split(MyProfile_Content, vbCrLf)
Dim sFix As String
For i As Integer = 0 To a.Length - 1
sFix = a(i)
If a(i).IndexOf("ID = ") >= 0 Then
sFix = sFix.Replace(a(i).IndexOf("ID = ") + 1, "1122334")
End If
MyProfile_StreamWriter.WriteLine(sFix)
Next
MyProfile_StreamWriter.Close()
Thanks.
Best Regards,
EK Tan
|
|
|
|
|
It has been too many years since I coded in VB so no example!
You are doing what I said would NOT work - Replace is not going to work in this case because you do not know what to replace. You cannot work character by character you need to work with a string.
Get the POSITION after ID = and put the string to the left into another string - your start string
Locate the next space after the POSITION + 2 - this is the start of the end string get everything to the right of that position, it is your end string
Concatenate the start string + your replacement text + the end string
add this to a new array of lines to be written out.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Can you split on "=" and then concat new text?
If a(i).IndexOf("ID = ") >= 0 Then
dim split2 as string() = Split(a(i), "ID =")
sFix = split2(0) + "ID = 1122334"
End If
|
|
|
|
|
Hi speedbump99,
Thanks for the guidance, the problem solved.
|
|
|
|
|
I have developed a program with VS2010 that sends multiple files to an ftp folder. I would like to find a way to verify, after uploading, if all the files have been uploaded correctly. What should I use the CRC or file length? Thank you.
|
|
|
|
|
"file length" doesn't verify the "contents".
So yes, you need a CRC or MD5 calculation to help determine if a file is corrupted or not.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry Schmitz wrote: So yes, you need a CRC or MD5 calculation to help determine if a file is corrupted or not.
thanks for the timely reply. Do you have any examples of crc or md5 verification code? Does the crc or md5 calculation do I have to do it on the local file or on the file uploaded to FTP or both? Thanks again
|
|
|
|
|
A typical CRC implementation involves:
1) Calc CRC for file
2) Add CRC to end of file
3) Transmit
4) Receiver parses / removes CRC from end of file received
5) Receiver recalcs CRC (for file "contents") and compares it with CRC received
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Check if the FTP server is supporting the File Transfer Protocol HASH Command for Cryptographic Hashes[^] (see at the bottom of that document for a list of FTP server software).
If so, you can create the hash for the local file using the same algorithm as marked in the FEAT response (or change the algorithm to be used) and compare it with the data returned from the HASH command.
[EDIT]
If not, check if the server supports one of the non-standard commands to return the check sum of a file. These are usually named like the algorithem.
[/EDIT]
Otherwise you would have to download the file to a different location and compare.
modified 2-May-18 11:08am.
|
|
|
|
|
Hi
Many apologies if this has been asked before, for the life of me I cannot find an answer (perhaps using the wrong search terminology).
Basically I've two tables in SQL - aircraft and status (they are linked with a foreign key) .
I've also got a form which has a combobox on it. This combobox contains 4 values which are located in status:
FMC
PMC
U/S
UNAVAIL
I've coded that part so that combobox displays above mentioned values (works fine):
Dim cboSelect As SqlDataAdapter = New SqlDataAdapter("SELECT condition FROM dbo.status", connection)
Dim cbox As New DataTable
cboSelect.Fill(cbox)
With cboServ
.DisplayMember = "condition"
.DataSource = cbox
End With
The problem I'm having is having the combobox display the actual value that is being used in the aircraft table. The record in aircraft (column name condition) is UNAVAIL. At the moment the Combobox defaults to FMC.
I know the SQL (well the query works whether its correct for VB or not I don't know)
SELECT condition FROM dbo.aircraft WHERE avNum='XXXXX'
Any help much appreciated TIA
|
|
|
|
|
Evenings im trying to solve this problem: i need to find all the possible results (using: +, -, *, /) from 4 numbers that we type in let´s say 4 text boxes and sho these results in a listbox or similar.
Im a bit lost as im no expert in programming and any help would be great
thanks in advance
|
|
|
|
|
Assuming only two numbers in each calculation. Then for each number, perform the operation with each of the other three numbers. In the case of add and multiply you need to check and ignore duplicate calculations.
|
|
|
|
|
Hi thank you for your reply. Im still trying to sort the math part of it. I think this involves over 2000 operations and if this is correct i dont think i can figure out the code cause really i dont know that much. I could do some "if" or "for each" or some "do while" stuff but if you guys think this is gonna take more than that please tell me
Thanks
|
|
|
|
|
I don't know where you got the number 2000 from, but maybe your original question was not complete.
|
|
|
|
|
Ok maybe i wasnt clear cause english is not my main language. We need to consider the 4 números everytime
Ex: a+b+c+d, a+b+c-d, a+b+c*d, a+b+c/d, etc
|
|
|
|
|
So the sequence is:
+ + +
+ + -
+ + *
etc.
I think that is a permutation of 3 out of 4 which is about 64 (a long time since I studied mathematics).
|
|
|
|
|
Exactly and also the numbers chance positivo aswel cause a/b is not the same as b/a
|
|
|
|
|
Sounds like a good candidate for a recursive algorithm.
To get the results for four numbers, you need to combine:
- The first number
+ the results for the other three numbers; - The first number
- the results for the other three numbers; - The first number
* the results for the other three numbers; - The first number
/ the results for the other three numbers;
For example:
Public Shared Function AllResults(ByVal ParamArray numbers() As Integer) As IEnumerable(Of Integer)
If numbers Is Nothing OrElse numbers.Length = 0 Then Return Enumerable.Empty(Of Integer)
Return AllResultsIterator(numbers, numbers.Length)
End Function
Private Shared Iterator Function AllResultsIterator(ByVal numbers As IEnumerable(Of Integer), ByVal length As Integer) As IEnumerable(Of Integer)
Dim n0 As Integer = numbers.First()
If length = 1 Then
Yield n0
Return
End If
For Each result As Integer In AllResultsIterator(numbers.Skip(1), length - 1)
Yield n0 + result
Yield n0 - result
Yield n0 * result
If result <> 0 Then Yield n0 \ result
Next
End Function NB: This will include duplicate results.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oh, this looks good, i will try it later. Many many thanks
|
|
|
|
|
First of all apologies if I posted in wrong forum and im a complete newbie to programming so need things idiot proof if you know what I mean.
What I need to do is I have a .vbs of which runs into a .DOS and need to add a few things. The person who wrote the original has since left my work where I got it from .
I have posted below parts of the script where I think it needs to go but if wrong just let me know and I will post the whole script.
1) When it puts it into a folder I need it to ask me to input a password . When password input I then need it to move onto the .VBA command of zipping
2) What I also need is instead of it just creating a 7Z file with the name of zipped.7z I need it to be the same name as what the folder was called originally.
1) Think needs to go here just before where it says "all files moved"...
On Error Goto 0
For Each objFile In objDLFolder.Files
objFSO.MoveFile objFile.Name, strNewFolder & "\"
Next
objWShell.Popup "All files moved.", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&
dim dotbat
set dotbat=createobject("wscript.shell")
dotbat.Run "C:\Users\icc.cctv\Documents\DONOTDELETE1.bat", 1, True
set dotbat=Nothing
2) I think it needs to go somewhere in there ...
cls&echo ENTER THE STATEMENT INTO FOLDER,
echo THIS WINDOW WILL CLOSE IN 5 SEC.
) else (
cls
7z a -t7z "C:\Downloads\zipped.7z" "C:\Downloads"
echo.&echo ALL FILES MOVED^^!
)
timeout 5 /NOBREAK >nul&exit/b
As said im compleely new so go easy on me please
|
|
|
|
|
glenn masters wrote: 1) When it puts it into a folder I need it to ask me to input a password . When password input I then need it to move onto the .VBA command of zipping You'd want to do that in the VBS part (not VBA, its not an application macro), as that has some easier ways to get user-input than the console has. Use the InputBox Function[^] and put the text into a variable.
glenn masters wrote: 2) What I also need is instead of it just creating a 7Z file with the name of zipped.7z I need it to be the same name as what the folder was called originally. So you'll need the original name of the folder that is being archived, do some string-manipulation probably to remove the path-part, and re-use that name when executing the archiving-command. Again, done from the VBS part; don't start adding it to the project at once; write it in a new VBS and get it working first, then integrate with the solution.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|