PDA

View Full Version : VB5 to Pic VB5 Help



l_gaminde
- 31st October 2010, 20:10
Im working on a VB5 to pic project, I need some help with a text box. Im unable to scroll data to this box using multiline and scroll bar, vbCrLf does not work chr(13) & chr(10) nothing works. if I put the vbCrLf as the first item on the line it drops down one line and prints all input on that line instead of scrolling.
This is time and date data from the pic and a 1307 rtc. I am able to scroll into a picture box using print. I have tried to break each byte out used the string, used formatting it all works in the picture window but scrolls off page, picture windows do not have scroll bars so some data gets lost.

rsocor01
- 2nd November 2010, 19:17
Hi,

Post your VB5 code and I might be able to tell you what is wrong.

Note: This is probably a wrong forum section to ask VB5 questions.

Robert

l_gaminde
- 2nd November 2010, 19:31
Yes on the wrong forum it is data from a Pic

Text1.Text = byte1 & byte2 & byte3

adding vbcrlf or chr(13) or chr(10) has no effect on text box
if I do
text1.text = " I feel like " vbcrlf will go to the next line
but variables will not

rsocor01
- 2nd November 2010, 19:53
Yes on the wrong forum it is data from a Pic

Text1.Text = byte1 & byte2 & byte3

adding vbcrlf or chr(13) or chr(10) has no effect on text box
if I do
text1.text = " I feel like " vbcrlf will go to the next line
but variables will not

Try it like this

Text1.Text = byte1 & vbcrlf & byte2 & vbcrlf & byte3

l_gaminde
- 2nd November 2010, 20:05
no it will not work with a variable
this is what I see from this
Text1.Text = mystr & vbCrLf & mystr & vbCrLf
88"88 88/88||88:88 88/88||
but when i copy and paste I get below it pastes with cr lf
This is really odd

88:88 88/88
88:88 88/88

The double lines are thicker I do not see them on my ansi chart

rsocor01
- 2nd November 2010, 20:35
I use VB6, but I am not familiar with VB5. However, they should be more or less the same.

Try a Label box instead of a Text box. The following code works fine for me, because I just took it from one of my working VB6 programs.


Label1.Caption = byte1 & vbcrlf & byte2 & vbcrlf & byte3

If you still insist in using a Text box, then the following might help you. This quote is taken from a VB6 help file.


To display multiple lines of text in a TextBox control, set the MultiLine property to True. If a multiple-line TextBox doesn't have a horizontal scroll bar, text wraps automatically even when the TextBox is resized. To customize the scroll bar combination on a TextBox, set the ScrollBars property.

Scroll bars will always appear on the TextBox when its MultiLine property is set to True, and its ScrollBars property is set to anything except None (0).

If you set the MultiLine property to True, you can use the Alignment property to set the alignment of text within the TextBox. The text is left-justified by default. If the MultiLine property is False, setting the Alignment property has no effect.

l_gaminde
- 4th November 2010, 23:59
Ok some of this worked and some did not I will be working on this again next week.
I have not given up just had problems (KIDS) thanks and will post more next week

l_gaminde
- 12th November 2010, 15:34
I use VB6, but I am not familiar with VB5. However, they should be more or less the same.

Try a Label box instead of a Text box. The following code works fine for me, because I just took it from one of my working VB6 programs.


Label1.Caption = byte1 & vbcrlf & byte2 & vbcrlf & byte3

If you still insist in using a Text box, then the following might help you. This quote is taken from a VB6 help file.

I tried your example and it worked but try this and let me know if it works for you


label1.Caption = byte1 & byte2 & byte3 & vbcrlf

now go through this 5 times and see if it goes to the next line or stays on one line

rsocor01
- 12th November 2010, 15:50
It stays on one line. Remember you are changing the caption of the label object.

Robert

l_gaminde
- 12th November 2010, 16:57
It stays on one line. Remember you are changing the caption of the label object.

Robert


Robert No I don't understand what your saying changing the caption Im lost
I want byte1 byte2 and byte3 on one line, then the next line down the same thing this is serial data so byte1-3 are different values on each line, there just being used for formatting a string value so the layout is simple and easy.

rsocor01
- 12th November 2010, 20:37
Robert No I don't understand what your saying changing the caption Im lost
I want byte1 byte2 and byte3 on one line, then the next line down the same thing this is serial data so byte1-3 are different values on each line, there just being used for formatting a string value so the layout is simple and easy.

l_gaminde,

For a Label, do the following,

Set the Multiline property of the label object to true. Also, make the scrollbars visible if you want to. End your command line with & vbcrlf like in the code that you posted


label1.Caption = byte1 & byte2 & byte3 & vbcrlf

For a Textbox, do the following,


Set Multiline to true
Set ReadOnly to true
Write your code like the following


textbox1.text = byte1 & byte2 & byte3 & VbCrLf 'This is the first line
textbox1.AppendText(byte1 & byte2 & byte3 & VbCrLf) 'These are the following lines

I'm not in front of my personal PC, so I haven't tested this code but it should work. Let me know if you have problems.

Robert

l_gaminde
- 12th November 2010, 22:13
l_gaminde,

For a Label, do the following,

Set the Multiline property of the label object to true. Also, make the scrollbars visible if you want to. End your command line with & vbcrlf like in the code that you posted


label1.Caption = byte1 & byte2 & byte3 & vbcrlfFor a Textbox, do the following,


Set Multiline to true
Set ReadOnly to true
Write your code like the following


textbox1.text = byte1 & byte2 & byte3 & VbCrLf 'This is the first line
textbox1.AppendText(byte1 & byte2 & byte3 & VbCrLf) 'These are the following linesI'm not in front of my personal PC, so I haven't tested this code but it should work. Let me know if you have problems.

Robert

ok the first one doesn't work, thats what I have been wondering about it sits on line one and changes per each set of inputs and never drops down vbcrlf chr(10) or 13 nothing works on the end of the line ?? works in the middle like your test but not at the end.
I will try the append thing now it will not read the first line textbox1.text again because I may have 30 to 100 or more lines to download

l_gaminde
- 12th November 2010, 22:19
l_gaminde,

For a Label, do the following,

Set the Multiline property of the label object to true. Also, make the scrollbars visible if you want to. End your command line with & vbcrlf like in the code that you posted


label1.Caption = byte1 & byte2 & byte3 & vbcrlfFor a Textbox, do the following,


Set Multiline to true
Set ReadOnly to true
Write your code like the following


textbox1.text = byte1 & byte2 & byte3 & VbCrLf 'This is the first line
textbox1.AppendText(byte1 & byte2 & byte3 & VbCrLf) 'These are the following linesI'm not in front of my personal PC, so I haven't tested this code but it should work. Let me know if you have problems.

Robert

Ok i tried the second part and it will not compile method or data member not found
and thats the Appendtext

l_gaminde
- 12th November 2010, 22:23
l_gaminde,

For a Label, do the following,

Set the Multiline property of the label object to true. Also, make the scrollbars visible if you want to. End your command line with & vbcrlf like in the code that you posted


label1.Caption = byte1 & byte2 & byte3 & vbcrlfFor a Textbox, do the following,


Set Multiline to true
Set ReadOnly to true
Write your code like the following


textbox1.text = byte1 & byte2 & byte3 & VbCrLf 'This is the first line
textbox1.AppendText(byte1 & byte2 & byte3 & VbCrLf) 'These are the following linesI'm not in front of my personal PC, so I haven't tested this code but it should work. Let me know if you have problems.

Robert

one more thing I have changed the byte1 -3 and its now mystr which is all formatted

l_gaminde
- 12th November 2010, 22:40
this is what my data looks like


4936

rsocor01
- 13th November 2010, 04:39
L_gaminde,

The next code works fine because I just tested it with VB6 in my PC. I expect that it should work for you too with your VB5 version.

- Create a textbox
- Set multiline to true
- Set scrollbars to "3 - both"
- Use the following code



Text1.text = Byte1 & vbCrLf 'This is the first line

Text1.SelStart = Len(Text1) 'Finds the starting point to append text
Text1.SelText = Byte2 & vbCrLf 'Appends text

Text1.SelStart = Len(Text1) 'Finds the starting point to append text
Text1.SelText = Byte3 & vbCrLf 'Appends text



Use the code for the first line only once if you want the results to keep scrolling.

Robert

Edit: The code I gave you in a previous post works for VB.net. Wrong version :( .

l_gaminde
- 13th November 2010, 18:41
This is what I tried

Text1.Text = mystr & vbCrLf
Text1.SelStart = Len(Text1) 'Finds the starting point to append text
Text1.SelText = mystr & vbCrLf 'Appends text



This is what I get!! two lines that both lines change as data comes in.

88:88 88/88
88:88 88/88

rsocor01
- 13th November 2010, 20:02
Like I said before, use the first line of code only once. Use the other two lines of code for the rest of the incomming data.

Using the first line again and again will "reset" the text in your textbox. If you need help post all your code. This code works fine because I tested it.

Robert

l_gaminde
- 13th November 2010, 20:37
I don't understand, I only used the first line once. I have one formatted variable mystr! Im getting this data through an oncomm when I get 9 bytes of data it fires and sets up my string sData, sData is then formatted into mystr, and mystr then sent to a file on disk and to a Picture box. I know if I have three lines it will print three lines!! I may have hundreds of lines so I really don't want to wirte 100 + text1.text lines, I want it to loop through the data as it comes in and put it on a line below the last. I have a counter running wonder if I can use the count value to tell the text box to drop one line and print can a text box be told which line to print on. This is basically a do loop where mystr is reloaded with new data each pass and then printed. Now when using the write or print commands with this data it works perfect but print and write do not work with a text box or lable box. Right now Im using to picture boxes when one fills up it goes on to the next but sometimes both fill up and I loose some data guess another picture box or two would help, bout could fill them also.




Public Sub MSComm1_ONComm()
If MSComm1.CommEvent = comEvReceive Then
sData = MSComm1.Input
cnt = cnt + 1
cnt1 = Format(cnt, "0#")
If Mid(sData, 1, 1) = "8" Then Command_End
mystr = Format(sData, " 0#:## 0#/## ")
FileNum = FreeFile ' Writes New Data To Disc (Named C:\Tracker)
Open "C:\Tracker.txt" For Append As FileNum
Print #FileNum, " "; cnt1 & " "; mystr
Close FileNum
If cnt <= 43 Then PicData1.Print " "; cnt1 & " "; mystr
If cnt > 43 Then PicData2.Print " "; cnt1 & " "; mystr
End If
End Sub

rsocor01
- 13th November 2010, 21:37
Ok, I will make it even simpler. This is the code I'm using to test the multiline feature


Option Explicit

Private Sub Command1_Click()
Dim MyNumber As Long
Dim I As Long

MyNumber = 0

For I = 0 To 50
Text1.SelStart = Len(Text1) 'Finds the starting point to append text
Text1.SelText = MyNumber & vbCrLf 'Appends text
MyNumber = MyNumber + 100
Next I

End Sub

And, this is the result

4942

Just try these two lines and they should work


Text1.SelStart = Len(Text1) 'Finds the starting point to append text
Text1.SelText = MyNumber & vbCrLf 'Appends text


Make sure you have the next settings correct

4943

l_gaminde
- 13th November 2010, 21:59
Just try these two lines and they should work

Text1.SelStart = Len(Text1) 'Finds the starting point to append text
Text1.SelText = MyNumber & vbCrLf 'Appends text

For Me Simple is really good!! THIS WORKS !! just changed the mynumber to mystr and bingo scrolls, Ok I just ( learnt somethin )

Thank You !!
you spent a lot of time helping! I appreciate it! there was someone else who could use this but forgot who ??

Thank You
Larry