我刚刚被这个错误阻止了
System.NullReferenceException was unhandled HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=System.Windows.Forms StackTrace:
at System.Windows.Forms.RichTextBox.StreamIn(String str, Int32 flags)
at System.Windows.Forms.RichTextBox.set_SelectedText(String value)
at Novania_JAV_Viewer_EncDec.Form1.Button1_Click(Object sender, EventArgs ef) in c:\users\toshiba\documents\visual studio
2010\Projects\Novania JAV Viewer EncDec\Novania JAV Viewer
EncDec\Form1.vb:line 91
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine)
at Novania_JAV_Viewer_EncDec.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart() InnerException:
这是我的全部代码,我正在尝试用一个单词替换所有字母,它需要一个一个替换一个变量。
错误位于此处(“标题”)字
Do Until RichTextBox1.Find("titelz") = -1
RichTextBox1.Find("titelz")
RichTextBox1.SelectedText = titel
这是我的整个表单类代码
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RichTextBox1.LoadFile("template.rtf")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal ef As System.EventArgs) Handles Button1.Click
Dim A As String
Replace(TextBox1.Text, "A", "5TY5")
Console.WriteLine(A)
Dim B As String
Replace(A, "B", "WEE")
Console.WriteLine(B)
Dim C As String
Replace(B, "C", "23RW")
Console.WriteLine(C)
Dim D As String
Replace(C, "D", "RW4R")
Console.WriteLine(D)
Dim E As String
Replace(D, "E", "DFS")
Console.WriteLine(E)
Dim F As String
Replace(E, "F", "R5")
Console.WriteLine(F)
Dim G As String
Replace(F, "G", "QWEDQ")
Console.WriteLine(G)
Dim H As String
Replace(G, "H", "ZDCZ")
Console.WriteLine(H)
Dim I As String
Replace(H, "I", "VGHN")
Console.WriteLine(I)
Dim J As String
Replace(I, "J", "ZSC")
Console.WriteLine(J)
Dim K As String
Replace(J, "K", "ZSD")
Console.WriteLine(K)
Dim L As String
Replace(K, "L", "WER")
Console.WriteLine(L)
Dim M As String
Replace(L, "M", "GN")
Console.WriteLine(M)
Dim N As String
Replace(M, "N", "xfv")
Console.WriteLine(N)
Dim O As String
Replace(N, "O", "DAASAD")
Console.WriteLine(O)
Dim P As String
Replace(O, "P", "WET")
Console.WriteLine(P)
Dim Q As String
Replace(P, "Q", "DFCV")
Console.WriteLine(Q)
Dim R As String
Replace(Q, "R", "ADSDA")
Console.WriteLine(R)
Dim S As String
Replace(R, "S", "SGFDG")
Console.WriteLine(S)
Dim T As String
Replace(S, "T", "SFSFD")
Console.WriteLine(T)
Dim U As String
Replace(T, "U", "AWDAD")
Console.WriteLine(U)
Dim V As String
Replace(U, "V", "RERE")
Console.WriteLine(V)
Dim W As String
Replace(V, "W", "GBGDBB")
Console.WriteLine(W)
Dim X As String
Replace(W, "X", " AWDAW ")
Console.WriteLine(X)
Dim Y As String
Replace(X, "Y", "AWDEAVA")
Console.WriteLine(Y)
Dim Z As String
Replace(Y, "Z", "AWEDWADW")
Console.WriteLine(Z)
Dim titel As String = Z
Do Until RichTextBox1.Find("titelz") = -1
RichTextBox1.Find("titelz")
RichTextBox1.SelectedText = titel
Loop
RichTextBox2.Text = RichTextBox1.Text
RichTextBox1.Clear()
RichTextBox1.LoadFile("template.rtf")
End Sub
End Class