Hi,
Chk it out..
Regards,
Pradeep
Printable View
Hi,
Chk it out..
Regards,
Pradeep
Finally i solved the problem.Thank u very much for the help provided by u. It was really very useful. it was a great application created by u.
So you could finally Learn some thing from that application.... Great!!.. :cool:Quote:
Finally i solved the problem.Thank u very much for the help provided by u. It was really very useful. it was a great application created by u.
Hi,
Sorry for troubling u again. I have another major problem again. Actally the text is by default aligned to the left. but i want it to be aligned in the center. How do i do it. Could u please help me out in this. Thanks.
I dont think that there is a direct method...
What you need to do is get the length of the text and then decide the PictureBox1.CurrentX value, this should be calculated..
Please post another question on how to put a text center to the picturebox.
Meanwhile I'll try... :D
Regards,
Pradeep
iam sending u a code.please check this out to center align text in picturebox. But i dont know how to implement this code in the code which u already sent.Just paste this code in a vb form along with a picturebox called picBox and a command button.
Private Const strData As String = "This is a sample text that should perhaps run " & _
"into more than three lines depending on the font " & _
"that is used to display the text in this picturebox." & _
"The technique I would suggest is to read this text into a " & _
"variable and split by a space and then print onto this " & _
"picture box depending on the position of the current " & _
"pixel in relation to the current font's TextHeight and/or TextWidth"
Private Sub Command1_Click()
Dim strDataArray() As String
Dim strToPrint As String
strDataArray = Split(strData, " ", -1, vbBinaryCompare)
i = 0
Do
If i > UBound(strDataArray) Then
Exit Do
End If
Do
If i > UBound(strDataArray) Then
Exit Do
End If
If (picBox.CurrentX + picBox.TextWidth(strToPrint & strDataArray(i))) > (picBox.ScaleWidth) Then
'i = i + 1
Exit Do
End If
strToPrint = strToPrint & strDataArray(i) & " "
picBox.CurrentX = (picBox.ScaleWidth - (picBox.TextWidth(strToPrint))) / 2
i = i + 1
Loop
picBox.Print strToPrint
strToPrint = ""
picBox.CurrentX = 0
Loop
End Sub
Private Sub Form_Load()
With picBox
.ScaleMode = vbPixels
.Font.Name = "Century Gothic"
.Font.size = 10
.Font.Bold = True
.Font.Italic = True
.AutoRedraw = True
End With
End Sub
The code works fine..
What you can do is read the code which I have sent you earlier and then try to think where you can insert this one.
ofcourse you can insert this piece of code in my code...
I dont want to do the whole thing, my intension is that you have to learn, give it a try else you will end up learning nothing.
Take this as an advice.
Hi,
good to know that u want me to learn something. But before i could post u this code and question i had already tried implementing it. the code gets hanged up in the middle and iam not able proceed further.
Ok... You send me what you have done.. I will have a look into it..
:D
Private Sub cmdRun_Click()
Dim i As Integer
Dim strStr As String
Dim tmp As Long
Dim st As String
'
Me.ScaleMode = 3
Picture1.ScaleMode = 3
Me.Show
Picture1.CurrentX = 250
speed = 1
Open FileName For Input As #1
While Not EOF(1)
Line Input #1, st
st = FormatText(st, 5)
st = splt(st)
strStr = strStr & vbCrLf & st
Dim strDataArray() As String
Dim strToPrint As String
strDataArray = Split(strstr, " ", -1, vbBinaryCompare)
i2 = 0
Do
If i2 > UBound(strDataArray) Then
Exit Do
End If
Do
If i2 > UBound(strDataArray) Then
Exit Do
End If
If (bg.CurrentX + bg.TextWidth(strToPrint & strDataArray(i2))) > (bg.ScaleWidth) Then
'i = i + 1
Exit Do
End If
strToPrint = strToPrint & strDataArray(i) & " "
bg.CurrentX = (bg.ScaleWidth - (bg.TextWidth(strToPrint))) / 2
i2 = i2 + 1
Loop
bg.Print strToPrint
strToPrint = ""
bg.CurrentX = 0
Loop
Wend
Close #1
strstr=strtoprint
strStr = strStr & vbCrLf & " "
i = bg.ScaleHeight - 20
UpDown = -1
mv = 1
While Not gmloop
DoEvents
If GetTickCount - tmp > speed Then
Picture1.Cls
bg.Cls
tmp = GetTickCount
bg.CurrentY = i
bg.Print strStr
bg.Refresh
' drawInverse
i = i + UpDown * mv * speed
End If
Wend
End
End Sub
this is what i did.
The code which you had posted earlier (Center justification)does the job..
So you dont have to call the formatText and splt functions..
try doing it..
Regards,
Pradeep
does your code work any way..??....
I dont think so.....
See the first while loop (Reading from the file..)
It ends much before..
Simply read the whole data to an array and then perform the rest of formatting (Center justification logic..)
Are you able to make sense of what I am saying.. :D
Do it and come up with some results...
sorry iam not able to follow what u'r saying.please explain it clearly
hi,
i was able to do till this. but after this how do i start scrolling. this code just prints the text in the picturebox.
Dim strDataArray() As String
Dim strToPrint As String
Open FileName For Input As #1
While Not EOF(1)
Line Input #1, st
'st = FormatText(st, 7)
'st = splt(st)
strStr = strStr & vbCrLf & st
Wend
Close #1
'strStr = strStr & vbCrLf & " "
strData = strStr
strDataArray = Split(strData, " ", -1, vbBinaryCompare)
i = 0
Do
If i > UBound(strDataArray) Then
Exit Do
End If
Do
If i > UBound(strDataArray) Then
Exit Do
End If
If (bg.CurrentX + bg.TextWidth(strToPrint & strDataArray(i))) > (bg.ScaleWidth) Then
'i = i + 1
Exit Do
End If
strToPrint = strToPrint & strDataArray(i) & " "
bg.CurrentX = (bg.ScaleWidth - (bg.TextWidth(strToPrint))) / 2
i = i + 1
Loop
bg.Print strToPrint
strToPrint = ""
bg.CurrentX = 0
Loop
Quote:
Originally posted by pradeepkrao
I am basically jobless . :D
You shouldn't be.
You should find out for who ayesha16 is working, and try to convince them you'll do a better job if they hire you.
;)
Ha ha ha.. I have a Job and fortunately I do it well within schedule :D .Quote:
You shouldn't be.
You should find out for who ayesha16 is working, and try to convince them you'll do a better job if they hire you.
rest of the day you will find me in vbforums.. :).
This is where I learnt VB from scratch.. :).
I advice this to all.. :)
Hi Ayesha,
Use the logic (Center justification) every time you move the text (Up or Down)
Sorry to tell u that it is not working out.If it is possible for u to explain properly please help me as iam supposed to submit this work by tomorrow.B'coz of this problem iam not able to concentrate on the rest of the work which i have to complete.
What.....
Quote:
not able to concentrate on the rest of the work which i have to complete.
Sir/Madam,Quote:
If it is possible for u to explain properly please help me as iam supposed to submit this work by tomorrow
Please try to understand the code. Have a look at it..
It is not as hard as it looks, give it a try...
Right Now I am buzy .. I will post you later..
Ayesha, are you a student or is this a work project?
I'm thinking its probably the student one, because I cant see how you'd be in a position to be given this task at work with the little knowledge you have.
After all the help Pradeep has given you, the least you could do is include him in the applications credits, though you wont do that as a student because then you will fail.
Shame that.
Agree with Lee. We are not here for doing your job, we are here to help each other. I would be mad if someone that i have helped alot said something like "please give me code that works!!".
Baaah!! :(