• RSS
  • Twitter
  • FaceBook

Security Forums

Log in

FAQ | Search | Usergroups | Profile | Register | RSS | Posting Guidelines | Recent Posts

Easy Visual Basic question......

Users browsing this topic:0 Security Fans, 0 Stealth Security Fans
Registered Security Fans: None
Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More

View previous topic :: View next topic  
Author Message
yellowman
Guest






PostPosted: Fri Apr 04, 2003 3:12 am    Post subject: Easy Visual Basic question...... Reply with quote

I am having a problem parsing some text and putting it into a spreadsheet. I have a text box that a user is going to put data in. Sometimes that data in the text box is going to be single line text, sometimes the data is going to span multiple lines. Then when I click a button the text from the text box is supposed to be added to one cell of the spread sheet. It works partially. The text is added to my spreadsheet, but it won't recognize mutiple line input. Every thing is always put in as single line input. Example of what is does

Text1:
aaaa
bbbbb

Excel: aaaa bbbbb

I want the excel cell to look identical to the text in Text1. Such as:

Text1:
aaaa
bbbb

Excel:
aaaa
bbbb

I have heard that I could use vbCrLf, but I don't know how to since the text in the text box will never be the same. Is there a way to code it so that each letter is parsed until an "end of line" character is reached then activate vbCrLf? Someone please help me!!!


Here is the code so far.

If (Headertxt2.Enabled = True) Then
Grid1.ActiveSheet.Cells(3, 1).Select
Grid1.Cells(3, 1).Value = Headertxt2.Value
Grid1.Cells(3, 1).Font.Size = 12
Grid1.Cells(3, 1).Font.Bold = True
Grid1.Cells(3, 1).Font.Name = CommonDialog1.FontName
Headertxt2.Value = Null
Headertxt2.Enabled = False
Headertxt2.BackColor = 12632256
End If
Back to top
Wombat
Trusted SF Member
Trusted SF Member


Joined: 24 Apr 2002
Posts: 0
Location: Canberra

Offline

PostPosted: Fri Apr 04, 2003 3:46 am    Post subject: Re: Easy Visual Basic question...... Reply with quote

yellowman wrote:
Is there a way to code it so that each letter is parsed until an "end of line" character is reached then activate vbCrLf?

vbCrLf is the "end of line" character! It's a VB constant denoting both a carriage return and line feed character: the letters stand for "visual basic carriage return line feed".

Use the InStr function to find the position of the first occurrence of the vbCrLf character in your string. Then you can split your string at that position. Repeat this as many times as needed.

Depending on your system, you may need one of the other similar things instead:


MSDN Library wrote:
The following string constants can be used anywhere in your code in place of actual values:

vbCr: Chr(13) - Carriage return
vbCrLf: Chr(13) & Chr(10) - Carriage return–linefeed combination
vbFormFeed: Chr(12) - Form feed; not useful in Microsoft Windows
vbLf: Chr(10) - Line feed
vbNewLine: Chr(13) & Chr(10) or Chr(10) - Platform-specific newline character; whatever is appropriate for the platform
vbNullChar: Chr(0) - Character having the value 0
vbNullString: String having value 0 Not the same as a zero-length string (""); used for calling external procedures
vbTab: Chr(9) - Horizontal tab
vbVerticalTab: Chr(11) - Vertical tab; not useful in Microsoft Windows
Back to top
View user's profile Send private message
yellowman
Guest






PostPosted: Fri Apr 04, 2003 3:45 pm    Post subject: inStr Reply with quote

Can you give an example on how to use the inStr function for my case? I have been reading on google and it confuses me a little Rolling Eyes
Back to top
Wombat
Trusted SF Member
Trusted SF Member


Joined: 24 Apr 2002
Posts: 0
Location: Canberra

Offline

PostPosted: Mon Apr 07, 2003 1:58 am    Post subject: Reply with quote

I can do better than that, I can point you to the example on the MSDN (Microsoft Developer Network) Library:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctinstrx.asp

I recommend you bookmark the MSDN Library, it has all the syntax for all MS languages, with examples. It's a very useful resource.
Back to top
View user's profile Send private message
Display posts from previous:   

Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More All times are GMT + 2 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Community Area

Log in | Register