Click here to Skip to main content
15,919,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,

How do i save a file with the text from a texbox .

The text in the textbox is a nummer.

What I have tried:

VB
<pre>workbook.Save(My.Application.Info.DirectoryPath & "\Reisdocumenten\ Form1.Reisnr.Text" & ".xlsx")


I think it has to be something like this but the outcome is

VB
From1.Reisnr.Text.xlsx


And not for example if the nummer in the textbox is 485

VB
485.xlsx
Posted
Updated 13-Jan-19 2:48am
v2

You have added the name of the text field inside the quotes so it is taken as part of the string. Try
VB
workbook.Save(My.Application.Info.DirectoryPath & "\Reisdocumenten\" & Form1.Reisnr.Text & ".xlsx")
 
Share this answer
 
Comments
BASSIES 13-Jan-19 8:58am    
Thanks Richard
Just an idea to add to previous solution, using interpolated string could make it simpler to spot these kinds of problems. In other words you could use

VB
workbook.Save($"{My.Application.Info.DirectoryPath}\Reisdocumenten\{Form1.Reisnr.Text}.xlsx")

Using this format the Visual Studio quite nicely shows with color coding which part is literal and which is not.

For more information, see $ (Visual Basic Reference) | Microsoft Docs[^]
 
Share this answer
 
v2
Comments
Richard MacCutchan 13-Jan-19 8:59am    
Is there a dollar sign missing in there?
Wendelius 13-Jan-19 9:02am    
Thanks! Now added.
OriginalGriff 13-Jan-19 9:01am    
You forgot the '$' string prefix.
Wendelius 13-Jan-19 9:02am    
Thanks! Now added.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900